# What is happening behind an evaluation of Sort with meaningless order-function?

If we try Sort[] with meaningless order-function like

Sort[{3, 2, 1}, True]


or,

Sort[{3, 2, 1}, False]


gives {3, 2, 1}, i.e., Sort[] does not do anything.

For the former case, I think it is natural because every comparison of two elements returns True, but what about the latter case?

I tried the visualization shown in the Wolfram document for Sort[], but I cannot understand why the sort converges.

First, True and False are not functions, they are just symbols. To demonstrate, evaluate

True[3, 2]


You should get back just True[3, 2] unevaluated. You can easily create a constant function, however, by just tacking on &:

True &[3, 2]


This time you should get back True.

So, in your original attempt, since you didn't get an actual boolean result for each comparison, no change was made. To force a constant comparison function, you could try these:

Sort[{3, 2, 1}, True &] (* {3, 2, 1} *)
Sort[{3, 2, 1}, False &] (* {1, 2, 3} *)

• Thank you for clarifying my question. Sorry for the fundamental mistake of me. Thank you very much! Jun 14, 2023 at 18:09