This is an issue in programming when numbers are stored as strings – because as strings, when sorted alphabetically they will go by each digit, from first to last. You might encounter this problem when dealing with file names, for example, which will be treated as strings but we might need to process them in order.
In our example below we use both the sort and strconv packages to sort the and convert the strings to numbers within our comparison function.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here