I've put some data in localStorage, and I want to retrieve to key names in an array, ordered by the value:
France : 0
Italy: 1
England: 2
Germany: 3
.. etc.
function getCountries() {
"use strict";
var returnArray = [];
for (var i = 0; i < localStorage.length; i++) {
returnArray.push(localStorage.key(i));
}
return returnArray;
}
Right now the order of the key-names in the array seems to be quite random - how to order the array by the values?
If you want to sort in multiple places you can create a prototype.
Created a fiddle of how to use it.