Largest and smallest values from concatenated integers This problem is from Five programming problems every Software Engineer should be able to solve in less than 1 hour which itself is an interesting read.  The first few problems are trivial, but the fourth one can be a bit more interesting.


  Given a list of integers separated by a single space on standard input, print out the largest and smallest values that can be obtained by concatenating the integers together on their own line.


For example:

Input:

5 56 50


Output: 

50556
56550


Various points of order:


The order of the results are smallest then largest.
Only the smallest and largest values may be printed out (iterating over all the variations and printing them out isn't valid).
There will always be two or more integers in the list.
It is possible for the largest and smallest results to be the same.  In the case of input 5 55, the number 555 should be printed twice.
The integers are not necessarily distinct. 5 5 is valid input.
Leading 0s on integers are not valid input.  You will not need to account for 05 55.


As this is code golf, shortest entry wins.
CJam, 14 13 bytes

qS/e!:s$(N@W=


Pretty straight forward. This is how it works:

qS/                  e# Split the input on spaces
   e!                e# Get all permutations of the input numbers
     :s              e# Join each permutation order into a single string
       $             e# Sort them. This sorts the strings based on each digit's value
        (N@W=        e# Choose the first and the last out of the array separated by '\n'


Try it online here