I have a list of Basic Type Now I order what I want to do, but I want to sort that list forward with the previous names. Do I have to divide it into 2 lists, a list of type Basically, I want to repeat a SQL type, where I'll type in You can: If you are sorting on several keys, then it will be cleaner: maps which I have already sorted in a way but Now I want to sort the list forward
Collections.sort (list, new comparison & lt; map & lt; string, object & gt; & Gt; () {@Override compare public int (map & lieutent; string, object & gt; m1, map & lt; string, object & gt; m2) {return m1.get ("type"). ToString (). Compare Switch to (m2.get ( "type"). ToString ()); // type 1 or 0}});
0 and other type with
1 then add the list together?
type ASC, last name ASC and sort me a sort of sort sorted sort by last name Would like to do
int compareType = m1 Get ("type") ToString () compareTo (m2.get ("type") toString ().); If (compareType! = 0) {return compare type; } Return m1.get ("name"). ToString () Compare (m2.get ("name"). ToString ());
for
(string key: new string [] {"type", "Name"}) {Int compare = m1.get (key) .toString (). Compare (m2.get (key) .toString ()); If (comparison! = 0) {compare comparison; }} Return 0;
No comments:
Post a Comment