see also http://www.ifadey.com/2013/04/sort-javascript-object-by-key-or-value/