score:1

Try forcing it to sort by numerical value instead of string. The unary + operator can accomplish that.

function getSortFunction(propertyName) {
    return function(a, b) {
        return +(a[propertyName]) > +(b[propertyName]);
    }
}

dataset.sort(getSortFunction("size"));

Related Query

More Query from same tag