improved sort button behaviour