java - Influence the order of digits and charachters in compare method -
i have wicket web application, sorts table rows in following order: ascending: first charachters (a-z) then numbers (1-9) now i'm writing webunit test test sorting mechanism, seems switch order of charachters , numbers like: ascending: first numbers (1-9) then charachters (a-z) so code fail, when sorting ascending , encounters 2 entries: ... zzz 111 ... my simplyfied sorting code: protected int compare(string val1, string val2) { return val1.compareto(val2); } what's "java way" of telling test code test order web application produces it? may collator ? prefer jre solution on selfwritten comparator on 3rd party library. you try using rulebasedcollator this: string rule = "<a,a<b,b<c,c<[...]<'1'<'2'<'3'<'4'[...]"; rulebasedcollator collator = new rulebasedcollator(rule); return collator.compare(val1,val2);