001package algs21; 002import stdlib.*; 003 004public class XSortCards00 { 005 public static void show (String title, String[] d) { 006 StdOut.println (title); 007 for (int i=0; i<4; i++) { 008 for (int j=0; j<13; j++) { 009 StdOut.format ("%3s ", d[i*13+j]); 010 } 011 StdOut.println (); 012 } 013 StdOut.println (); 014 } 015 public static void main (String[] args) { 016 String[] d = { 017 "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "10C", "JC", "QC", "KC", "AC", 018 "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "10D", "JD", "QD", "KD", "AD", 019 "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "10H", "JH", "QH", "KH", "AH", 020 "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "10S", "JS", "QS", "KS", "AS" }; 021 show ("Initial", d); 022 StdRandom.shuffle (d); 023 show ("Shuffled", d); 024 Selection.sort (d); 025 show ("Sorted", d); 026 } 027}