First, your original program is bad programming practice when the values are integers. It works for characters, but I would avoid this bad programming practice.
, , ; , int, x y, int, x y, , . . (, x y , x y, x - y .)
. :
- . A == B B == C, A C. A < B B < C A C. .
- . , A < B B > A, .
. - .
nodes.Sort((x, y) => x < y ? -1 : (x > y ? 1 : 0));
, NaN. NaN, , .
, . , , e , z, , z , é, , , , . ; , , ?
. ; :
http://ericlippert.com/2011/01/20/bad-comparisons-part-one/