fix: support natural ordering for numbers with >12 digits (#652)

* fix: support natural ordering for numbers with >12 digits

Changes the column ordering code when `view_options.natural_order`
is enabled, so that it can support larger numbers.

The previous 12-digit padding approach breaks for numbers above 12
digits.

This length-prefixed approach can scale to much higher numbers.
I picked %03 (padding 3 digits) because most filesystems don't allow
more than 255 bytes in a path segment, and "255" is 3 digits long.

* add memoization to natural order sorting

* remove call to unpack
This commit is contained in:
XeroOl 2025-08-20 21:22:30 -04:00 committed by GitHub
parent bbad9a76b2
commit 07f80ad645
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 10 deletions

View file

@ -587,7 +587,7 @@ local function get_sort_function(adapter, num_entries)
end
return function(a, b)
for _, sort_fn in ipairs(idx_funs) do
local get_sort_value, order = unpack(sort_fn)
local get_sort_value, order = sort_fn[1], sort_fn[2]
local a_val = get_sort_value(a)
local b_val = get_sort_value(b)
if a_val ~= b_val then