Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 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