what is the Javascript code for sorting an HTML list alphabetically? for example:
NBA Teams:
- Sacramento Kings
- Chicago Bulls
- Atlanta Hawks
- Indiana Pacers
- LA Lakers
- Boston Celtics
I want to make the list automatically sorted alphabetically after loading the page (without the need to press a button).
so the result will be:
- Atlanta Hawks
- Boston Celtics
- Chicago Bulls
- Indiana Pacers
- LA Lakers
- Sacramento Kings
this is close to what i want but with a button https://www.w3schools.com/howto/howto_js_sort_list.asp