Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
7
Task/Sort-stability/JavaScript/sort-stability.js
Normal file
7
Task/Sort-stability/JavaScript/sort-stability.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
ary = [["UK", "London"], ["US", "New York"], ["US", "Birmingham"], ["UK", "Birmingham"]]
|
||||
print(ary);
|
||||
|
||||
ary.sort(function(a,b){return (a[1]<b[1] ? -1 : (a[1]>b[1] ? 1 : 0))});
|
||||
print(ary);
|
||||
|
||||
/* a stable sort will output ["US", "Birmingham"] before ["UK", "Birmingham"] */
|
||||
Loading…
Add table
Add a link
Reference in a new issue