reorder list by recrusive function