Fix buffer sorting.

Bug introduced in 4ef6e889b8f1c1bc0edabfa3d922d13b48148e43