I have some strings mixed up, each starts with a number. They need to be sorted by this number. I know they can be put into arrays and bubble sorted, but this is apparently inefficient. What is a better method to sort them in a certain way?
Also, say if I had a method that took a single string. I then wanted to store that string so that when the method is called again with a different string it is compared to the stored string. How do I maintain the storage?
use a static string variable declare it above Page_Load line like:
static string yourstrVariable = "";
it will hold its value which you can compare in the function
altenately you can store a string value inside session as well, and in the method, first check weather
the session value is null or not, if not, use it
Usman Waheed
Marked as answer by Amy Peng - MSFT on Dec 21, 2012 12:28 AM
damon2012
Member
21 Points
107 Posts
Help with best way to sort
Dec 13, 2012 08:47 PM|LINK
Hi,
I have some strings mixed up, each starts with a number. They need to be sorted by this number. I know they can be put into arrays and bubble sorted, but this is apparently inefficient. What is a better method to sort them in a certain way?
Also, say if I had a method that took a single string. I then wanted to store that string so that when the method is called again with a different string it is compared to the stored string. How do I maintain the storage?
Thanks.
usman400
Contributor
3503 Points
721 Posts
Re: Help with best way to sort
Dec 14, 2012 04:03 AM|LINK
there are recommendations for each sorting algorithm based on provided data you have
search google with query: Comparison of Sorting Algorithms
if you have time dive in the following PDF:
http://www.scribd.com/doc/23730874/Comparison-of-All-Sorting-Algorithms
use a static string variable declare it above Page_Load line like:
static string yourstrVariable = "";
it will hold its value which you can compare in the function
altenately you can store a string value inside session as well, and in the method, first check weather
the session value is null or not, if not, use it