emericg / OpenSubtitlesDownload

Automatically find and download the right subtitles for your favorite videos!
https://emeric.io/OpenSubtitlesDownload
GNU General Public License v3.0
607 stars 66 forks source link

Selection Table sorts number alphabetically #81

Closed GoulartNogueira closed 1 month ago

GoulartNogueira commented 3 years ago

When I run the script, a pop-up appears so I can select an option. There I can see the number of rating and downloads.

Problem:

When I click on a column header to sort that list, numbers sorted alphabetically:

10
2
300
4
500
51
6
75
...

Expected:

Numbers sorted numerically:

2
4
6
10
51
75
300
500
...

What I've tried:

            subtitlesItems += '"' + item['SubDownloadsCnt'] + '" '

Removing " from entry:

            subtitlesItems += ' ' + item['SubDownloadsCnt'] + ' '

Code works normally, but still sorted like numbers are string.

I believe it's something about zenity. But I'm not sure.

emericg commented 3 years ago

Indeed this doesn't seem to work. I tried a couple of things, including integer number, or real number with dots or comma to try and force zenity to handle them as numbers. I also try similar things directly in bash. If there is a solution to this problem, it isn't documented either...

JayKuswahey commented 1 year ago

Might it be an option to pad the numbers, so you can leave the type alone?

002
004
006
010
051
075
300
500

Can't code myself out of a paper bag though... :(

emericg commented 11 months ago

Ok I wanted to try padding the numbers as a workaround, but it looks like the latest zenity version doesn't even bother sorting the texts anymore, so...

emericg commented 4 months ago

Well what do you know, text sorting is back on latest zenity releases :/

I'm committing the "padding hack" for the download counts, if someone wants to try it. It's not pretty, but it does work as intended. I don't know if I'll keep it in in the future. Also note that the subtitles scores, which are real numbers, are already sorted by zenity without issue.

emericg commented 1 month ago

Numerical sorting (through zero padded strings) has been included for a while without complaints, I'm closing this issue.