I started learning JavaScript a week ago, and I made a sorting function on my own. It does work, but I need reviews and how to write a better one.

```
<body>
<ul id="list">
    <li>Art</li>
    <li>Mobile</li>
    <li>Education</li>
    <li>Games</li>
    <li>Magazines</li>
    <li>Sports</li>
</ul>

var list = document.getElementById("list");
var myList = list.getElementsByTagName("li");
var a = [];
for (var i = 0; i < myList.length; i++) {
    a[i] = myList[i].innerHTML;
}
a.sort();
for (var i = 0; i < myList.length; i++) {
    myList[i].innerHTML = a[i];
}

```

Output:

> 
> * Art
> * Education
> * Games
> * Magazines
> * Mobile
> * Sports
> 
> 
>