You got the idea but it's a bit trickier than that
The sort button shows you only the end result, if you do "view source" you can see the list elements have not really changed place... you basically need a real-time viewer for the html code, then you c/p that into your epub.
The solution you talked about can be good if you want to allow the user to sort the TOC.
EDIT:
Oh, never mind, I found something that will help you:
1. After you sort your list, in Chrome hit F12.
2. Use the find button and hit the first element in the visual sorted list, the end result.
3. In the code window you will see the code is focused on the first element you searched for. (see attached)
4. Right click <html>
5. Copy as HTML
6. Open Notepad++, paste
voila, you have the sorted list you were looking for.