forked from nkronlage/JavaScripture
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollator.jsdoc
More file actions
73 lines (58 loc) · 2.04 KB
/
collator.jsdoc
File metadata and controls
73 lines (58 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Collator : Object
Collator provides language aware comparison of %%/String|Strings%% for
sorting and searching.
Available through %%/Intl#Collator%%.
Spec:
http://www.ecma-international.org/ecma-402/1.0/#sec-10
----
Collator([locales : Array<String>, [options : Object]]) : Collator
Same as %%#new_Collator|**new Intl.Collator(locales, options)**%%.
----
new Collator([locales : Array<String>, [options : { \
caseFirst : Boolean /* */, \
ignorePunctuation : Boolean /* */, \
localeMatcher : String /* One of **'basic'** or **'best fit'**. */, \
numeric : Boolean /* */, \
sensitivity : String /* One of **'base'**, **'accent'**, **'case'**, or **'variant'**. */, \
usage : String /* One of **'sort'** or **'search'** */ \
}]]) : Collator
<example>
</example>
----
instance.compare(value1 : String, value2 : String) : Number
Compares two string values to determine which should come first
if they were sorted alphabetically according to the locales
of the Collator. Returns **0** if **value1** is the same as **value2**,
a negative value if **value1** should come before **value2**, and
a positive value if **value1** should come after **value2**.
Can be passed to %%/Array#sort|Array.sort()%% to sort a list of strings.
<example>
var collator = Intl.Collator();
console.log(collator.compare('a', 'a'));
console.log(collator.compare('a', 'b'));
console.log(collator.compare('b', 'a'));
var letters = ['c', 'a', 'd', 'b'];
console.log(letters.sort(collator.compare));
</example>
----
prototype.resolvedOptions() : { \
caseFirst : Boolean /* */, \
collation : String /* */, \
ignorePunctuation : Boolean /* */, \
locale : String /* */, \
numeric : Boolean /* */, \
sensitivity : String /* */, \
usage : String /* */ \
}
<example>
var options = Intl.Collator().resolvedOptions();
for (var property in options) {
console.log(property + ': ' + options[property]);
}
</example>
----
supportedLocalesOf(locales : Array<String>, [options : { \
localeMatcher : String /* One of **'basic'** or **'best fit'**. */ \
}]) : Array<String>
<example>
</example>