sort lists before output