Sort vector { 6, 4, 5 }: { 4, 5, 6 } Sort vector { 6, 4, 5 }: { 4, 5, 6 } Reverse vector { 6, 4, 5 }: { 5, 4, 6 } Indices that sort the vector { 6, 4, 5 }: { 1, 2, 0 } Sort vector { 9, 7, 8 } respective to the previously determined indices: { 7, 8, 9 } Take the two first and last elements of vector { 6, 4, 5 }: { 6, 4 }, { 4, 5 } Sort the vector { 6, 4, 5 }, take the two last elements and reverse the selection: { 6, 5 }