reorder list, implementing a non-recursive reverse function