Add data source sorting via events.

merge sort code adapted from http://stackoverflow.com/questions/7685/merge-sort-a-linked-list