java - Sort Arraylist containing both numbers and letters -
this current arraylist:
arraylist<string> myarraylist = new arraylist<string>(); [102423;asd.com, 49952;qwe.com, 76933;rty.com, 199526;fgh.com, 139388;jkl, 25114;qaz, 155766;ghj.com, 321339;vbn.com, 210513;kol.com]
and want sort them numbers. ive tried following:
collections.sort(myarraylist) for(string counter : myarraylist){ system.out.println(counter); }
but not working. im thinking splitting collections.sort dont know how pair them togehter again.
use collections.sort(list<t> list, comparator<? super t> c)
static method , supply custom comparator compare()
method extracts numeric prefix 2 elements , compares prefixes.
you use string.split(";")
numeric prefix, example.
Comments
Post a Comment