sort (had to complicate a bit)