PageSourceSearch

https://railspoons.co.uk/sort.js?v=

js railspoons.co.uk collected 2026-10-04 12:31:15 UTC 771 bytes, 18 lines download raw bytes

1"use strict";
2
3const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent
4
5const comparer = (idx, asc) => (a, b) => ((v1, v2) => 
6    v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
7    )(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
8
9// do the work...
10
11document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
12  const table = th.closest('table');
13  Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
14    .sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
15    .forEach(tr => table.appendChild(tr) );
16  myFunction(Array.from(th.parentNode.children).indexOf(th), this.asc, kfrom);
17})));
18

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.