I am currently building a sort system, and I want to sort these four elements, which all have the same class.

```js
      function sortByOrdnr() {

        var allaOrdnr = document.getElementsByClassName("ordernummer");

        var antal = allaOrdnr.length;

        var listWithAllaOrdnr = [];
        for (var i = 0; i < antal; i++) {
          listWithAllaOrdnr.push(allaOrdnr[i]);
        }

        listWithAllaOrdnr.sort() // [A, B, C, E]

        console.log(listWithAllaOrdnr);
        for (var i = 0; i < antal; i++) {
          document.getElementsByClassName("ordernummer")[i] = listWithAllaOrdnr[i];

        }

      }
```

```html
<button onclick="sortByOrdnr()"> Button </button>

    <p class="ordernummer"> A </p>
    <p class="ordernummer"> E </p>
    <p class="ordernummer"> B </p>
    <p class="ordernummer"> C </p>
```

In the end, I want the classes to change position, so that the four elements are sorted when clicking on the button, like this:

```
<p class="ordernummer"> A </p>
<p class="ordernummer"> B </p>
<p class="ordernummer"> C </p>
<p class="ordernummer"> E </p>

```

I appreciate all the help. Thanks in advance.