I understand how ternary operators work. It's still hard to read if you inline multiple ternary operators the way OP suggested is easy. It adds cognitive complexity, and hides bugs because your brain will fill the details on what it assumes it does, versus the subtleties of what it actually does.
In fact, it is obviously so confusing that to make it work someone suggested the introduction of white-space and multiple lines, as follows:
return
(a < b) ? -1 : // a smaller
(a > b) ? 1 : // a greater
0; // equal
And they still got it subtly wrong, because the semantics of their 'fix' makes it seem like it is the equivalent of: if(a < b)
return -1;
else if(a > b)
return 1;
else
return 0;
which isn't quite true. It's actually: if(a < b)
return -1;
else
if(a > b)
return 1;
else
return 0;
Will this make a difference in this case? No - but there is a subtle semantic difference that you have to stop to consider when you're scanning this code.