Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Best way to sort 2 strings alphabetically

Posted on 2004-08-05
4
Medium Priority
?
217 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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

610 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