我在任何地方都找不到使用collator.compare排序对象的任何示例。有人可以提供吗?到目前为止,我遇到的所有文档和示例都涉及到show array sorting,如下所示:
var myArray = ['1_Document', '11_Document', '2_Document'];
var collator = new Intl.Collator(undefined, {numeric: true, sensitivity: 'base'});
myArray.sort(collator.compare)
Run Code Online (Sandbox Code Playgroud)
很高兴看到它如何对像
var objs = [{name: '1_Document', size: 40}, {name: '11_Document', size: 50}, {name: '2_Document', size: 60}];
Run Code Online (Sandbox Code Playgroud)