fixed some sort bugs