I have a list of resolution strings like `2160p`, `1080p`, `720p`, `480p` that I’d like to be sorted from biggest to smallest. I’ve tried removing the trailing `p` using `replace(…)` and then simply sorting them, but it still ends up putting `2160p` after `1080p` for example.
I have the same system working for alphabetically sorting resolution strings like `UHD`, `FHD`, `HD` but want to support both.
@DesertCookieauthorMay 18.2020 — #@Sempervivum#1618553 Thanks for the suggestion. It sorts everything correctly, except for 2160p, which it puts at the end of the list, right after 360p :/ .
@SempervivumMay 18.2020 — #I tested it by use of this code: let res = ['2160p', '1080p', '720p', '480p']; res.sort((a, b) => { return (parseInt(a) - parseInt(b)); }); console.log(res); and it works fine for me. If it does not for you, please post your code.
@DesertCookieauthorMay 19.2020 — #It seems I had to wait a couple of problems for the changes to take effect. Just reloading the page and clearing the cache didn't do the trick. (Firefox and Webpage via localhost).