sort edges by postion of source and target node