diff options
author | Alexis Nootens <me@axn.io> | 2016-02-02 19:28:33 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-02-02 19:58:51 +0100 |
commit | 8996f79edbf4286807d5255b6db68550aa473951 (patch) | |
tree | 9832b41ae136b0d810c73accfccdc70797b6be9c /TOOLS/lua | |
parent | b7e613f261c1b21ab2c9f4477d331edadfd561b2 (diff) | |
download | mpv-8996f79edbf4286807d5255b6db68550aa473951.tar.bz2 mpv-8996f79edbf4286807d5255b6db68550aa473951.tar.xz |
TOOLS/lua/autoload.lua: remove the extension prior to sort
When the directory contains files named such as xx-14.ext and
xx-14.5.ext, remove the extension to sort the table to load the
14 before the 14.5.
Diffstat (limited to 'TOOLS/lua')
-rw-r--r-- | TOOLS/lua/autoload.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/TOOLS/lua/autoload.lua b/TOOLS/lua/autoload.lua index 0c8c9a5381..1f22bb40e2 100644 --- a/TOOLS/lua/autoload.lua +++ b/TOOLS/lua/autoload.lua @@ -72,6 +72,11 @@ function find_and_add_entries() return EXTENSIONS[string.lower(ext)] end) table.sort(files, function (a, b) + local len = string.len(a) - string.len(b) + if len ~= 0 then -- case for ordering filename ending with such as X.Y.Z + local ext = string.len(get_extension(a)) + 1 + return string.sub(a, 1, -ext) < string.sub(b, 1, -ext) + end return string.lower(a) < string.lower(b) end) |