collator

How can I sort by property using a collator ? (Java)

我与影子孤独终老i 提交于 2021-01-29 11:23:23
问题 (I use Java) I want to sort a sublist of objects by a property using a Collator so that is sorted by alphabetical order but ignoring accents. Problem is I have tried different things and none work. This sorts the sublists but doesn't ignore accents: newList.subList(0, 5).sort(Comparator.comparing(element -> element.getValue())); This is the collator I want to use: Collator spCollator = Collator.getInstance(new Locale("es", "ES")); I expect the output to be a sublist sorted by alphabetical

Javascript how to sort array of objects by numeric value of the string [duplicate]

半腔热情 提交于 2020-06-23 09:46:12
问题 This question already has answers here : Sort array of strings by integer (which is the first character) (3 answers) Sort Array Elements (string with numbers), natural sort (8 answers) Closed 2 years ago . Below is an example of my array of objects and I am supposed to sort these by name. The js normal sorting sorts as shown below, however my target is to sort by the numeric value, eg: "1 ex, 2 ex, 3 ex, 4 ex, 11 ex ..". Could someone help me how to achieve this? [{id: 588, name: "1 ex"} {id:

Javascript how to sort array of objects by numeric value of the string [duplicate]

China☆狼群 提交于 2020-06-23 09:45:38
问题 This question already has answers here : Sort array of strings by integer (which is the first character) (3 answers) Sort Array Elements (string with numbers), natural sort (8 answers) Closed 2 years ago . Below is an example of my array of objects and I am supposed to sort these by name. The js normal sorting sorts as shown below, however my target is to sort by the numeric value, eg: "1 ex, 2 ex, 3 ex, 4 ex, 11 ex ..". Could someone help me how to achieve this? [{id: 588, name: "1 ex"} {id:

Intl.Collator for JS Objects

妖精的绣舞 提交于 2019-12-10 14:23:54
问题 I am not able to find any example of sorting objects using collator.compare anywhere. Can anyone provide ? All the documentation and examples so far I came across show array sorting as example below: var myArray = ['1_Document', '11_Document', '2_Document']; var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'}); myArray.sort(collator.compare) Would be good to see how this works for objects like var objs = [{name: '1_Document', size: 40}, {name: '11_Document', size: