how to use sort function the same way as max or min in mathematica

Posted by Qiang Li on Stack Overflow See other posts from Stack Overflow or by Qiang Li
Published on 2011-01-14T00:51:12Z Indexed on 2011/01/14 0:53 UTC
Read the original article Hit count: 179

Filed under:

Please take a look at the following code:

Sort[{1, y, x}, Greater]
Max[{1, x, y}]
x = 1
y = 2
Sort[{1, y, x}, Greater]
Max[{1, x, y}]

It is interesting to note that the first Sort always produce a definite result while the first Max does not, even when Greater is specified. Note I have not given any numerical values for x and y. Why is this and how can I have a Sort function behave the same way as the Max (or Min) function?

Thanks!

© Stack Overflow or respective owner

Related posts about mathematica