New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest autoload.lua is sorting case sensitive #4398

sleek22 opened this Issue May 4, 2017 · 0 comments


None yet
1 participant

sleek22 commented May 4, 2017

I'm not sure if I had modified my old version of autoload.lua but it sorted case insensitive, as Windows sorts its files (the behavior I want), i.e., "apple" comes before "Pear".

I am not a programmer but it has these lines:

table.sort(files, function (a, b)
return string.lower(a) < string.lower(b)

The new autoload.lua is sorting capital letters first and then lowercase after, i.e., "Pear" comes before "apple" which is different compared to how they sort in a Windows directory. It has these lines:

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)
return string.lower(a) < string.lower(b)

From an article on lua scripting that I just looked at is the following:

As a typical use, if you want to sort an array of strings regardless of case, you may write something like

table.sort(a, function (a, b)
  return string.lower(a) < string.lower(b)

Since I see the line "return string.lower(a) < string.lower(b)" in both the old autoload.lua and the new autoload.lua, why is the new one sorting different?

@wiiaboo wiiaboo closed this in 95d5fe1 May 4, 2017

atomnuker added a commit to atomnuker/mpv that referenced this issue Jun 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment