Nodejs Utililty Methods Object Sort

List of utility methods to do Object Sort

Description

The list of methods to do Object Sort are organized into topic(s).

Method

ksort(obj)
function ksort(obj) {
    if (!obj || typeof (obj) != 'object') {
        return [];
    var keys = [], values = [];
    for (var i in obj) {
        keys.push(i);
    keys.sort();
...
sortByValue(toSort)
function sortByValue(toSort) {
    var keys = Object.keys(toSort);
    keys.sort(function(a, b) {
        return toSort[a] < toSort[b] ? -1 : (toSort[a] === toSort[b] ? 0 : 1);
    });
    return keys;