I have a list of functions and their derivatives.
How can I select the function and its derivative with the smallest or largest index, provided that both the function and its derivative are in the list?
For example, given the list
vars = {U[1][t], U[2][t], U[3][t], U[5][t], U[6][t], U[7][t], U[3]'[t], U[5]'[t], U[6]'[t]}
,
I want to select the function and its derivative with the smallest index, which would be {U[3][t], U[3]'[t]}
.