2021年5月4日星期二

how to naturally sort a list that contains simillar values

i have a list of strings like this: ['id:9', 'vector:1', 'table:1', 'product:10', 'number:3', 'Number:4']

i want to sort it from higher integer value to lower and then the rest: ['product:10', 'id:9', 'Number:4', 'number:3', 'vector:1', 'table:1']

the values are all integer without including 0, the string that are attached to them can be all lower case, all upper case, part lower case, part upper case, while also being similar to another item: Number, NUMBER, number, NUMber

i tried using natsort but that didn't arrange them correctly, also i tried some other solutions discussed here still didn't work in my case, so how can this be done in python?

https://stackoverflow.com/questions/67394623/how-to-naturally-sort-a-list-that-contains-simillar-values May 05, 2021 at 11:00AM

没有评论:

发表评论