C# Array number sorting
Posted
by
athgap
on Stack Overflow
See other posts from Stack Overflow
or by athgap
Published on 2010-12-22T10:37:23Z
Indexed on
2010/12/22
10:54 UTC
Read the original article
Hit count: 212
Hi, I have an array of numbers jumbled up from 0-9.
How do I sort them in ascending order?
Array.Sort doesn't work for me. Is there another way to do it?
Thanks in advance.
EDIT: Array.Sort gives me this error.
Argument 1: cannot convert from 'string' to 'System.Array'
Right now it gives me this output:
0) VersionInfo.xml
2) luizafroes_singapore2951478702.xml
3) virua837890738.xml
4) darkwizar9102314425644.xml
5) snarterz_584609551.xml
6) alysiayeo594136055.xml
1) z-a-n-n2306499277.xml
7) zhangliyi_memories932668799030.xml
8) andy_tan911368887723.xml
9) config.xml
k are the numbers from 0-9
string[] valnames = rk2.GetValueNames();
foreach (string k in valnames)
{
if (k == "MRUListEx")
{
continue;
}
Byte[] byteValue = (Byte[])rk2.GetValue(k);
UnicodeEncoding unicode = new UnicodeEncoding();
string val = unicode.GetString(byteValue);
Array.Sort(k); //Error here
richTextBoxRecentDoc.AppendText("\n" + k + ") " + val + "\n");
}
© Stack Overflow or respective owner