You have to SetTextAreaText(textarea,"") to clear the current text and then you have to add the text again with AddAreaText.
Or you load the sorted text into one string seperated with the newline char ('~n') and use SetTextAreaText with this string directly.
Or you load the sorted text into one string seperated with the newline char ('~n') and use SetTextAreaText with this string directly.