code for transformation of u and v is the same in ascending and descending