switch to custom sort comparitor
| @@ -836,6 +836,14 @@ function randValuesCallback(from, to, args) { | ||
| 836 | 836 | return value; |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | +function customSortComparitor(a, b) { | |
| 840 | + if (typeof a != typeof b) { | |
| 841 | + a = typeof a; | |
| 842 | + b = typeof b; | |
| 843 | + } | |
| 844 | + return a > b ? 1 : a < b ? -1 : 0; | |
| 845 | +} | |
| 846 | + | |
| 839 | 847 | function sortArrayObjectCallback(args, value) { |
| 840 | 848 | let parsedValue; |
| 841 | 849 | if (typeof value == 'string') { |
| @@ -850,13 +858,13 @@ function sortArrayObjectCallback(args, value) { | ||
| 850 | 858 | } |
| 851 | 859 | if (Array.isArray(parsedValue)) { |
| 852 | 860 | // always sort lists by value |
| 853 | 861 | parsedValue.sort(customSortComparitor) |
| 854 | 862 | } else if (typeof parsedValue == 'object') { |
| 855 | 863 | let keysort = args.keysort; |
| 856 | 864 | if (isFalseBoolean(keysort)) { |
| 857 | 865 | parsedValue = Object.keys(parsedValue).sort(function(a,b){return customSortComparitor(parsedValue[a]-, parsedValue[b])}); |
| 858 | 866 | } else { |
| 859 | 867 | parsedValue = Object.keys(parsedValue).sort(customSortComparitor); |
| 860 | 868 | } |
| 861 | 869 | } |
| 862 | 870 | return JSON.stringify(parsedValue); |