replaced ordering algorithm with batagelj's