Monday, 15 March 2010

sorting - How to sort .net Arraylist containing ListItems, by Value -



sorting - How to sort .net Arraylist containing ListItems, by Value -

dim alcustomers new arraylist dim li1 new listitem("john", 7) alcustomers.add(li1) dim li2 new listitem("abe", 2) alcustomers.add(li2)

how can sort alcustomers arraylist, value?

abe,2

john,7

in c# .net 3.5 or newer work this:

// create list of listitem objects list<listitem> alcustomers = new list<listitem>(); // add together list items alcustomers.add(new listitem("john", 7)); alcustomers.add(new listitem("abe", 2)); var orderedcustomers = alcustomers // order items value... .orderby(item => item.value) // , convert list. .tolist();

unfortunately since lastly version of visual basic used vb6, not sure how translate that. best guess:

// create list of listitem objects dim alcustomers new list(of listitem) // add together list items alcustomers.add(new listitem("john", 7)) alcustomers.add(new listitem("abe", 2)) dim orderedcustomers list(of listitem) = alcustomers // order items value... .orderby(function(item listitem) item.value) // , convert list. .tolist(of listitem)()

.net sorting arraylist

No comments:

Post a Comment