The code below reads in a string, splits the string into an array with every comma. Then alphabetically sorts the array and re-joins the string with a comma in between (and also removes that last comma afterwards).
|
If my input string is " UE-CA , UF-BA , UF-AB , OF-AB ," , I want my output string to be " UE-CA , UF-AB , OF-AB , UF-BA". However my code below will output it as " OF-AB , UE-CA , UF-AB , UF-BA". The problem occurs with OF-AB f.
I would like to sort the array by ignoring the first letter of the each string, but still output the same result above.
I appreciate any help and thank you in advance. Also, I know my coding method might be questionable, but it sort of works.
Roei BarPosted Oct 8, 2009, 12:28 PM
foreach (string s in
stringSplit
{s.Replace('-','');
}
and after that when you build
add the '-' again