I want to sort a list like this...
blue, 56 The Drive, colour red, my number is 7, green
...into...
56 The Drive, blue, colour red, green, my number is 7
i.e. numbers first, then letters. Notice that "my number is 7" does not have 7 at the beginning of the sentence and so should be sorted according go the letters.
Ideally, I want to create a function that lets me pass a multiline string, have it sort in a-z or z-a. I've been trying to sort(), reverse() join("\n") and split("\n") but getting nowhere fast.
Any ideas?
Update: The following code almost works. What is wrong is that it will show the capitals first e.g. Alpha, Zoo, age, zap. I want it to show age, Alpha, zap, Zoo. So how can I modify my code to ignore the Capitalisation part of the sort?
if (status === 'A-Z') {
tmpStr = tmpStr.split('\n').sort().join('\n');
} else {
tmpStr = tmpStr.split('\n').sort().reverse().join('\n');
}
return tmpStr;
};```