it sorts the strings and compares only adjacent elements in slices