[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Best way to sort 2 strings alphabetically

Posted on 2004-08-05
4
Medium Priority
?
219 Views
Last Modified: 2010-04-15
What's the best way to sort 2 string alphabetically?
0
Comment
Question by:natejacobs
  • 2
4 Comments
 
LVL 9

Expert Comment

by:noulouk
ID: 11726610
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
 
LVL 4

Expert Comment

by:NTAC
ID: 11727195
What are you trying to do?
0
 
LVL 3

Author Comment

by:natejacobs
ID: 11729148
I'm sorting a list view when a column is clicked.
0
 
LVL 9

Accepted Solution

by:
noulouk earned 1000 total points
ID: 11731186
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month19 days, 8 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question