Suppose I have a function f that takes a vector v and returns a new vector with the elements transformed in some way. It does that by calling function g that assumes the vec
Here's a "sorting wrapper" pattern suggested by Michael Pilat earlier
Clear[g]; g[a_] := If[OrderedQ[a], a^2, Print["Failed"]]; g[{3, 2, 1}] g[a_] := g[Sort@a][[Ordering@Ordering@a]] /; Not[OrderedQ[a]]; g[{3, 2, 1}]