I have an array list that is set up in this type of style...
- 4 dogs
- 10 cats
- 2 dogs
And I want to sort it so the ArrayList will be in the order of...
- 1 dogs
- 4 dogs
- 10 cats
Without using a comparator or another method, what is the shortest, easiest way to sort these by taking out the numbers (splitting the string by the space " "?), comparing them, and putting the sorted results back into the ArrayList? If you could attach your code snippet, it would be much appreciated.