Given an array of non-negative numbers, output the largest and smallest possible number that can be formed by joining them.

Input,Output can be in any convenient format.

The array may have at most 1 decimal number.

```
input:[22,33,44,55.55,33]
output:4433332255.55,55.5522333344
input:[34,900,3,11,9]
output:990034311,113349009
input:[99.93,9,3,39]
output:939399.93,99.933399
input:[45.45,45,45,45]
output:45454545.45,45.45454545
input:[12,21,34,43,45.1]
output:4334211245.1,45.112213443
```

This is **code-golf** so shortest code wins.

TFeld 11/15/2018.

`lambda a:[''.join(sorted(a,key=lambda s:'.'in s or s+s)[::i])for i in[-1,1]]`

_{-2 bytes, thanks to Arnauld}

Emigna 11/15/2018.

`œJΣ'.¡ï}Á2£`

Try it online!or as a Test Suite

**Explanation**

```
œ # get permutations of input
J # join each
Σ } # sort by
'.¡ # splitting into [before decimal, after decimal]
ï # and converting each to int
Á # rotate the result right
2£ # and take the first 2 values
```

Arnauld 11/15/2018.

`a=>[1,-1].map(n=>a.sort((a,b)=>[a%1||a]+b<[b%1||b]+a?n:-n).join``)`

We use the following test to compare two values in the input array:

`[a % 1 || a] + b < [b % 1 || b] + a`

The expression `x % 1 || x`

returns the decimal part of \$x\$ if \$x\$ is a decimal number, or leaves \$x\$ unchanged otherwise.

The expression `[x % 1 || x] + y`

coerces the above result to a string and concatenates it with the other value.

If there's a decimal number in the list, it must always be considered as the smallest value. By applying our conversion, a decimal number is turned into a string starting with `"0."`

, which is lexicographically ordered before anything else.

*Examples:*

```
a | b | [a%1||a]+b | [b%1||b]+a
----+-----+------------+------------
4 | 5 | "45" | "54"
10 | 11 | "1011" | "1110"
8 | 80 | "880" | "808"
7 | 9.5 | "79.5" | "0.57"
```

Shaggy 11/15/2018.

Erik the Outgolfer 11/15/2018.

`Œ!VṢ.ị`

Explanation:

```
Œ!VṢ.ị Arguments: x
Œ! Permutations of x
V Concatenate the representations of each permutation's elements and evaluate the result as Jelly code
Ṣ Sort
.ị Get element at index 0.5, i.e. elements at indices 0 (last) and 1 (first)
```

Travis 11/16/2018.

Sok 11/15/2018.

`hM_BSvsM.p`M`

Outputs in form `[smallest, largest]`

. Try it online here, or verify all the test cases at once here.

```
hM_BSvsM.p`MQ Implicit: Q=eval(input())
Trailing Q inferred
`MQ Stringify all elements of Q
.p Generate all permutations of the above
sM Concatenate each permutation
v Evaluate each as a number
S Sort them
_B Pair the sorted list with its reverse
hM Take the first element of each, implicit print
```

*Edit: Saved a byte by taking stringification out of the mapping function. Previous version:* `hM_BSmvs`Md.p`

nwellnhof 11/15/2018.

`{.max,.min}o+<<*.permutations.map(*.join)`

Alternatives:

```
{.max,.min}o+<<*.permutations.map:{.join}
{.max,.min}o{[map +*.join,.permutations]}
{.max,.min}o{+<<map *.join,.permutations}
```

BMO 11/15/2018.

`§,▼▲morṁsP`

```
§,▼▲m(rṁs)P -- example input: [2,3,1.1]
P -- permutations: [[2,3,1.1],[3,2,1.1],[1.1,3,2],[3,1.1,2],[1.1,2,3],[2,1.1,3]]
m( ) -- map the following
(example with [1.1,2,3])
ṁs -- | show each and join: "1.123"
r -- | read: 1.123
-- : [231.1,321.1,1.132,31.12,1.123,21.13]
§, -- fork and join as tuple
▼ -- | min: 1.123
▲ -- | max: 321.1
-- : (1.123,321.1)
```

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

- Largest and smallest values from concatenated integers
- Most logical rectangle formula from numbers
- Find the largest and the smallest number in an array
- Smallest sum (and largest difference) of two 3-digit integers
- Output the largest number with the fewest digits
- How long is my number?
- How many partitions contain only perfect squares?
- Smallest unseen, but no sharing digits!
- Elliptic system
- Make the biggest and smallest numbers

- Pulling numbers out of a file name
- What would happen if someone had a telescope and watched Betelgeuse when it goes supernova?
- US citizen previously refused entry into the UK and been refused for visa. What to do now?
- Is a scheme Noetherian if its topological space and its stalks are?
- What was the colour of the shoes used by the Apollo astronauts in moon landing?
- I don't know why my D string is showing a C♯ on my tuner
- accidentally deleted /var/lib/apt/
- how to get 30 minute break while working or doing anything on computers?
- How can I convey and sustain a level of realism in a given campaign?
- Why is it possible to invert the screen?
- How to make a metal with extraordinary property worthless?
- Suddenly it's announced that my train won't go the my destination, is my Sparpreis ticket valid?
- Find the number of leading zeroes in a 64-bit integer
- How to upgrade a package in Debian 8?
- Why did J. K. Rowling choose to downplay dragons?
- When change of variable makes an empty interval
- How long could a nuclear war head remain functioning underground?
- Difference between /əʳ/ and /ɚ/
- Was there a Japanese equivalent of the Gestapo during WW2
- The math behind Warren Buffet's famous rule – never lose money
- Could you do acrobatics and long-distance running in an ankle-length dress?
- I'm scheduled to graduate next week but my professor has gone MIA due to a death in the family... what can I do?
- Why is Arrays.asList(...).toArray().getClass() giving different results in JDK 1.8 and 11?
- Four boys are playing football and one of them breaks a window