reorder, O(N)+O(1)