Fix sort() bug when ids.length is 0. Fixes #74