Task
 
Given a set of positive integers, write a function to order the integers in such a way that the concatenation of the numbers forms the largest possible integer and return this integer.

Use the following two sets of integers as tests   and   show your program output here.

   {1, 34, 3, 98, 9, 76, 45, 4}
   {54, 546, 548, 60}


Possible algorithms

 A solution could be found by trying all combinations and return the best. 
 Another way to solve this is to note that in the best arrangement, for any two adjacent original integers X and Y, the concatenation X followed by Y will be numerically greater than or equal to the concatenation Y followed by X.
 Yet another way to solve this is to pad the integers to the same size by repeating the digits then sort using these repeated integers as a sort key.


See also

   Algorithms: What is the most efficient way to arrange the given numbers to form the biggest number?
   Constructing the largest number possible by rearranging a list


/* NetRexx */
options replace format comments java crossref symbols nobinary
 
runSample(arg)
return
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method largestInt(il) public static
  ri = ''
  wa = ''
  -- put the list into an indexed string
  wa[0] = il.words
  loop ww = 1 to wa[0]
    wa[ww] = il.word(ww)
    end ww
 
  -- order the list
  loop wx = 1 to wa[0] - 1
    loop wy = wx + 1 to wa[0]
      xx = wa[wx]
      yy = wa[wy]
      xy = xx || yy
      yx = yy || xx
      if xy < yx then do
        -- swap xx and yy
        wa[wx] = yy
        wa[wy] = xx
        end
      end wy
    end wx
 
  -- rebuild list from indexed string
  loop ww = 1 to wa[0]
    ri = ri wa[ww]
    end ww
  return ri.space(0) -- concatenate the list elements into a single numeric
 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
  ints = [ -
    '1 34 3 98 9 76 45 4', -
    '54 546 548 60' -
    ]
  loop il over ints
    say largestInt(il).right(20) ':' il.space(1, ',')
    end il
  return
 