An interesting solution by Simon Schönbeck that also works in Google spreadsheet.
Suppose you have some strings in a sheet with different lengths. All you need to do is to create a second column, select the first cell, insert the function
=LEN(A1) and then drag down:
Now, by selecting both columns, go to
Data→Sort Range and sort by column
B. Since column
B contains numbers representing the length of the strings in column
A will be sorted as well by string length.
The pairwise difference between cells in a column can be calculated using the
OFFSET excel command:
Applying the formula to all rows (by dragging), will result in the following table:
You can also use
ABS in the offset formula:
=ABS(OFFSET(C2, -1, -2, 1, 1)-OFFSET(C2, 0, -2, 1, 1))
in order to avoid negative values.