I received a question today on how to sort a list of strings which was actually rather simple to accomplish.
The following list is the original sorting:
- caca
- cocacola
- ca
- cacacacacola
- c
- cacacacacacacaac
- cacaa
The requested list after sorting should look like this:
- c
- ca
- caca
- cacaa
- cocacola
- cacacacacola
- cacacacacacacaac
What I first did was to create a separate column to contain the length of each cell. There is a function in Excel which easily calculates the length of a string: LEN(). Now I had two columns, the first unsorted string column and the second length (of the first column string) column. As you probably have realised by now it was a simple matter of sorting the second column instead of the first for the strings to sort by length.
If interested in seeing it I have attached the test sheet for you to play around with: