Best way to sort 2 strings alphabetically

What's the best way to sort 2 string alphabetically?
LVL 3
natejacobsAsked:
Who is Participating?
 
nouloukCommented:
Hi natejacobs,

I often use something like this:

int result = string.Compare(str1,str2,true);
 in which str1 and str2 are the strings you wish to compare and true means ignore casing (false means make a casesensitive comparison).

Test the result of the Compare function. If result = 0 then the strings are equal. If the result is a negative number, then str1 comes before str2 alphabetically. If the result is a positive number, then str1 comes after str2 alphabetically

Hope this helps.

0
 
NTACCommented:
What are you trying to do?
0
 
natejacobsAuthor Commented:
I'm sorting a list view when a column is clicked.
0
All Courses

From novice to tech pro — start learning today.