Simpler way of sorting three numbers

if (a > c)
   swap(a, c);

if (a > b)
   swap(a, b);

//Now the smallest element is the 1st one. Just check the 2nd and 3rd

if (b > c)
   swap(b, c);

Note: Swap changes the values of two
variables.

Leave a Comment