hack-spots icon indicating copy to clipboard operation
hack-spots copied to clipboard

Ordering by value not accurate enough

Open Krukarius opened this issue 5 years ago • 4 comments

I have some values such a:

43

12 5 11 16 18 51

when sorted by table, I got:

11 12 16 18 18 43 5 51

Could you tell me where can I fix the code and make these values in right order?

Krukarius avatar Nov 21 '19 17:11 Krukarius

That comes in from the Sheetsee.js dependency; https://github.com/jlord/sheetsee-tables/blob/master/index.js#L20 looks to be your point of interest. It's doing a ASCIIbetical sort.

deltamualpha avatar Nov 21 '19 20:11 deltamualpha

Hi,

I tried twice the example https://github.com/jlord/sheetsee-tables/blob/master/index.js#L20, but I see no reaction at all.

The code, coming from there feature only ShowInfo function, which is the same in your project. I entered sheetsee.js and found possibly relevant stuff inside:

1506 line: var sortable = [] for (var category in count) { sortable.push([category, count[category]]) } sortable.sort(function(a, b) {return b[1] - a[1]}) return sortable // returns array of arrays, in order }

7905 line: queue.sort(function (a, b) { return a.distanceTo(center) - b.distanceTo(center); });

16138 line:

module.exports.sortThings = sortThings function sortThings(opts, sorter, sorted, tableDiv) { if (opts.tableDiv != tableDiv) return opts.data.sort(function(a,b){ if (a[sorter]<b[sorter]) return -1 if (a[sorter]>b[sorter]) return 1 return 0 }) if (sorted === "descending") opts.data.reverse() makeTable(opts) var header $(tableDiv + " .tHeader").each(function(i, el){ var contents = resolveDataTitle($(el).text()) if (contents === sorter) header = el }) $(header).attr("data-sorted", sorted) }

Any advice cordially appreciated! Thank you

Krukarius avatar Nov 27 '19 11:11 Krukarius

@Krukarius hack-spots isn't my project; I just used to use it for a site (i've since rewritten it to not use sheetsee.js since I didn't need most of its functionality).

The sheetsee.js in this repository is a compiled, minified version of the one that I linked to above. If you want to modify it, you should fork sheetsee-tables, make your changes, compile+minify a version that has the sorting you want, then add it to your fork of hack-spots.

deltamualpha avatar Nov 27 '19 14:11 deltamualpha

OK, thanks. So in this event maybe someone else can advise?

Krukarius avatar Nov 27 '19 20:11 Krukarius