Click here to Skip to main content
15,908,661 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sort string array alphanumericlly Pin
SilverAdder21-Aug-08 4:15
SilverAdder21-Aug-08 4:15 
AnswerRe: Sort string array alphanumericlly Pin
J4amieC20-Aug-08 5:05
J4amieC20-Aug-08 5:05 
Im just playing round with LINQ for the first time, so here i'll show you that solution.

You'll see this test code outputs the 3 numbers 3 times

1) Original Order
2) Default Sort which is the wrong order for you
3) Ordered using the first group of numbers followed by the second group of numbers - this should be the order you're looking for

string[] myStrings = { "123_456", "123_12", "123_123567" };
foreach (string s in myStrings)
    Console.WriteLine(s);

Console.WriteLine();

Array.Sort(myStrings);
foreach (string s in myStrings)
    Console.WriteLine(s);

Console.WriteLine();

var sortedRight = from s in myStrings.OfType<string>() 
                  orderby int.Parse(s.Split('_')[0]), int.Parse(s.Split('_')[1]) 
                  select s; 

foreach(string s in sortedRight)
    Console.WriteLine(s);

Console.ReadLine();


Output:
123_456
123_12
123_123567

123_12
123_123567
123_456

123_12
123_456
123_123567

QuestionOutlook pst processing, creating and manipulation in C# Pin
hmnt0520-Aug-08 3:23
hmnt0520-Aug-08 3:23 
QuestionMore than project in one setup file Pin
M7mad_t20-Aug-08 3:14
M7mad_t20-Aug-08 3:14 
Questionshow AutoCompleteList Pin
KeDaiv20-Aug-08 3:05
KeDaiv20-Aug-08 3:05 
QuestionVS template Wizard Pin
V.20-Aug-08 2:43
professionalV.20-Aug-08 2:43 
AnswerRe: VS template Wizard Pin
led mike20-Aug-08 4:44
led mike20-Aug-08 4:44 
GeneralRe: VS template Wizard Pin
V.20-Aug-08 22:46
professionalV.20-Aug-08 22:46 
QuestionC# to Java converter? Pin
hairy_hats20-Aug-08 1:33
hairy_hats20-Aug-08 1:33 
AnswerRe: C# to Java converter? Pin
Christian Graus20-Aug-08 1:34
protectorChristian Graus20-Aug-08 1:34 
GeneralRe: C# to Java converter? Pin
hairy_hats20-Aug-08 1:41
hairy_hats20-Aug-08 1:41 
AnswerRe: C# to Java converter? Pin
blackjack215020-Aug-08 1:59
blackjack215020-Aug-08 1:59 
AnswerRe: C# to Java converter? Pin
lisan_al_ghaib20-Aug-08 2:05
lisan_al_ghaib20-Aug-08 2:05 
QuestionPass multiple command line arguments to a system process Pin
thestonefox20-Aug-08 1:06
thestonefox20-Aug-08 1:06 
AnswerRe: Pass multiple command line arguments to a system process Pin
lisan_al_ghaib20-Aug-08 2:00
lisan_al_ghaib20-Aug-08 2:00 
GeneralRe: Pass multiple command line arguments to a system process Pin
thestonefox20-Aug-08 2:08
thestonefox20-Aug-08 2:08 
GeneralRe: Pass multiple command line arguments to a system process Pin
lisan_al_ghaib20-Aug-08 2:20
lisan_al_ghaib20-Aug-08 2:20 
GeneralRe: Pass multiple command line arguments to a system process Pin
thestonefox20-Aug-08 2:24
thestonefox20-Aug-08 2:24 
GeneralRe: Pass multiple command line arguments to a system process Pin
lisan_al_ghaib20-Aug-08 2:28
lisan_al_ghaib20-Aug-08 2:28 
GeneralRe: Pass multiple command line arguments to a system process Pin
thestonefox20-Aug-08 2:30
thestonefox20-Aug-08 2:30 
GeneralRe: Pass multiple command line arguments to a system process Pin
lisan_al_ghaib20-Aug-08 2:39
lisan_al_ghaib20-Aug-08 2:39 
AnswerRe: Pass multiple command line arguments to a system process Pin
Mark Salsbery20-Aug-08 7:23
Mark Salsbery20-Aug-08 7:23 
GeneralRe: Pass multiple command line arguments to a system process Pin
thestonefox20-Aug-08 22:29
thestonefox20-Aug-08 22:29 
GeneralRe: Pass multiple command line arguments to a system process Pin
Mark Salsbery21-Aug-08 5:37
Mark Salsbery21-Aug-08 5:37 
QuestionWIA Scanner Pin
jugal_piet@indiatimes.com20-Aug-08 0:05
jugal_piet@indiatimes.com20-Aug-08 0:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.