Sorting text starting with number

Just a silly little tip I’m putting up in here for my own reference.

If for whatever silly reason you ever need to sort a list of specific text such as:

[ 4 Apple, 2 Donkey, 1 Monkey ]

Just split the number and text using splitby or regex then splitby, add 100, join them back then sort away!

Don’t forget to deduct extract the sum and subtract 100 then rejoin when trying to store or display the text!

If you have to ask why i do this, just know that i could have done other better ways but time was short and trouble needed shooting!

1 Like