Skip to main content
1 of 3
Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60

R, 105 bytes

function(l,a=expand.grid(rep(list(l),3)),b=apply(a[rowSums(a)==max(l),],1,sort))b[,order(b[3,]-b[1,])[1]]

Try it online!

Dominic van Essen
  • 36.4k
  • 2
  • 22
  • 60