One should write a black-box version of filesort.cc that is not depending of MySQL and put this into mysys. Then one should change myisam/sort.cc to use the new filesort interface. This should be one so that we have only one copy of the sort code. The code in sql/filesort.cc is newer and more general than myisam/sort.cc, so one should use this as a base for this.
