solved sorting problem