Sorting a number of DIV’s

I’m trying to write a sort function but it keeps going of the rails, gets to complicated.

  • imagine 10 div’s in a container div.
  • people can click the div’s, those appear in a summary box up top.
  • People can click div 8 then div 2 then div 5 for example.
  • but in the summary box i’d like them to be sorted, so div 2, then div
    8 then div 8.

preferably in plain JS, no jquery.

I was thinking of writing what people click to an array with maybe push() or splice(), and then filling the summary box with it somehow, but haven’t managed yet.