Added edge sorting.