Finally got the sort-join implementation working.