sort things correctly