001package algs21;
002import stdlib.*;
003/* ***********************************************************************
004 *  Compilation:  javac Sort6.java
005 *  Execution:    java Sort6 a b c d e f
006 *
007 *  Reads in six integers and prints them out in sorted order without
008 *  using a loop. Uses 12 compare-exchanges.
009 *
010 *************************************************************************/
011
012public class XSort6 {
013        public static void main(String[] args) {
014
015                // read in 6 command-line integers to sort
016                int a = Integer.parseInt(args[0]);
017                int b = Integer.parseInt(args[1]);
018                int c = Integer.parseInt(args[2]);
019                int d = Integer.parseInt(args[3]);
020                int e = Integer.parseInt(args[4]);
021                int f = Integer.parseInt(args[5]);
022                if (a > b) { final int t = b; b = a; a = t; }
023                if (c > d) { final int t = d; d = c; c = t; }
024                if (e > f) { final int t = f; f = e; e = t; }
025                if (c > e) { final int t = e; e = c; c = t; }
026                if (a > c) { final int t = c; c = a; a = t; }
027                if (b > d) { final int t = d; d = b; b = t; }
028                if (d > f) { final int t = f; f = d; d = t; }
029                if (b > c) { final int t = c; c = b; b = t; }
030                if (d > e) { final int t = e; e = d; d = t; }
031                if (b > d) { final int t = d; d = b; b = t; }
032                if (c > e) { final int t = e; e = c; c = t; }
033                if (c > d) { final int t = d; d = c; c = t; }
034                StdOut.println(a + " " + b + " " + c + " " + d + " " + e + " " + f);
035        }
036}