开发者

What is a good sorting algorithm that obeys conditions?

开发者 https://www.devze.com 2023-01-22 21:28 出处:网络
My goal is to sort a designer.cs\' InitializeComponent()\'s statements for merging.I used coco-r to set up a dependency graph.This gives me certain conditions that need to be true.(If calling a method

My goal is to sort a designer.cs' InitializeComponent()'s statements for merging. I used coco-r to set up a dependency graph. This gives me certain conditions that need to be true.(If calling a method on an object make sure that the order of the methods if the same before and after the sort.)

I was curious if there are any sorting algorithms which would output a sorted list that would obey these conditions. The only thing I can think开发者_StackOverflow of is the brute forcing approach of moving items up by alphabetical order and checking conditions after each move. Then if the conditions no longer hold undo the last action and try moving the next item up.


I think you're looking for a topological sort.

0

精彩评论

暂无评论...
验证码 换一张
取 消