?
Solved

Best way to sort 2 strings alphabetically

Posted on 2004-08-05
4
Medium Priority
?
215 Views
Last Modified: 2010-04-15
What's the best way to sort 2 string alphabetically?
0
Comment
Question by:natejacobs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

764 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