Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADIR and ASORT for .NET ?
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01020162
Message ID:
01021091
Views:
24
Yuri,
I have not found an easy way to sort a 2 dim array natively with .NET but there is an interesting overload method of Array.Sort() that might assist you. Here is some quick code to show how it works(the example in the docs is also good)
			string[] sa = new string[5];
			sa[0] = @"c:\it\a.bak";
			sa[1] = @"c:\it\e.bak";
			sa[2] = @"c:\it\c.bak";
			sa[3] = @"c:\it\b.bak";
			sa[4] = @"c:\it\d.bak";

			string[] sb = new string[5];
			sb[0] = "20050604";
			sb[1] = "20050602";
			sb[2] = "20050609";
			sb[3] = "20040604";
			sb[4] = "20050704";

			MessageBox.Show(sb[0]+":"+sa[0]+"\n"+sb[1]+":"+sa[1]+"\n"+sb[2]+":"+sa[2]+"\n"+sb[3]+":"+sa[3]+"\n"+sb[4]+":"+sa[4],"before");
			
			// sort each array idependently
			//Array.Sort(sa);
			//Array.Sort(sb);

			// "link" the arrays using an overload method
			Array.Sort(sb,sa);
			
			MessageBox.Show(sb[0]+":"+sa[0]+"\n"+sb[1]+":"+sa[1]+"\n"+sb[2]+":"+sa[2]+"\n"+sb[3]+":"+sa[3]+"\n"+sb[4]+":"+sa[4],"after");
Hope this helps.

Einar

PS. in order to sort an array the array needs to be traversed (even in vfp) so even if you want to sort the array so you can to a while loop all the elements of the array has to be examined. <bg>
Semper ubi sub ubi.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform