switching sort take to min by