bug: corruption after sort