Working sort and output