PageSourceSearch

https://ukairquality.net/Scripts/utils/sorter.js?v=4.272.8.29%20(23.58)

js ukairquality.net collected 2026-10-08 15:48:10 UTC 1,635 bytes, 51 lines download raw bytes

1
2function Sorter() {
3    this.sortByStringField = function (array, field) {
4
5        if (array != null) {
6            return array.sort(sortAux)
7        }
8
9        function sortAux(a, b) {
10
11
12            if (b[field] == null) {
13                return 1;
14            }
15            else if (a[field] == null) {
16                return -1;
17            }
18
19            var aName = a[field].toLowerCase();
20            var bName = b[field].toLowerCase();
21            return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
22        }
23    }
24
25    //if sortDesc is true, values go from high to low.
26    // sorted by the selected field attribute of the array. for numeric field values
27    this.sortByNumericField = function (array, field, sortDesc) {
28        if (JsUtils.isArray(array)) {
29            array.sort((a, b) => {
30                const firstValue = sortDesc ? a[field] : b[field];
31                const secondValue = sortDesc ? b[field] : a[field];
32
33                // Handle empty values
34                if (JsUtils.isEmpty(firstValue)) return -1;
35                if (JsUtils.isEmpty(secondValue)) return 1;
36
37                // Compare numeric values
38                if (JsUtils.isNotEmpty(firstValue) && JsUtils.isNotEmpty(secondValue)) {
39                    return firstValue === secondValue
40                        ? 0
41                        : firstValue < secondValue
42                            ? 1
43                            : -1;
44                }
45            });
46        }
47
48        return array; // Return the original array if not valid
49    };
50}
51var sorter = new Sorter()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.