({
take: [
{ key: "nbs", type: "list", label: "Numbers" },
{ key: "asc", type: "toggle", label: "Sort ascending", value: true },
],
make: ({ nbs, asc }) => {
const f = asc ? 1 : -1
const v = (v) => (Number.isNaN(+v) ? f * Infinity : +v)
nbs.unshift("-- These items weren't sorted --")
return nbs.sort((a, b) => {
let [x, y] = [a, b].map(v)
return x === y ? 0 : f * (x > y ? 1 : -1)
})
},
})