correct ordering algorithm