accepted solution for sort list problem