improve sorting

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>