working sort functinos, NEED TO FIX resizing function