我想找到一种有效的方法(最好是在Perl中)通过比较它们在组的多个子集中的顺序来学习单词族的固定顺序.(它们是工作参数.大约有30种不同的工作参数.不同的工作需要不同的参数组合,每个工作中只有一些参数)
例如,给定:
first
second
third
sixth
seventh
tenth
first
third
fourth
fifth
sixth
third
fifth
seventh
eighth
ninth
tenth
Run Code Online (Sandbox Code Playgroud)
它应该能够记住它看到的相对顺序关系,以确定订单是:
first
second
third
fourth
fifth
sixth
seventh
eighth
ninth
tenth
Run Code Online (Sandbox Code Playgroud)
我已生成如下列表:
first.second.third.sixth.seventh.tenth
first.third.fourth.fifth.sixth
third.fifth.seventh.eighth.ninth.tenth
Run Code Online (Sandbox Code Playgroud)
然后按字母顺序排序+视觉比较它们,但我有30个参数的数百种不同的组合,所以将它们全部排序并手动将它们放在一起将是一项大工作.
我认为@ daniel-tran已经回答了/sf/answers/3362936041/中的"如何" 并使用了这个和一些hackery:
$order->{$prev}->{$this} = 1;
$order->{$this}->{$prev} = 0;
Run Code Online (Sandbox Code Playgroud)
我设法为每对连续参数填充哈希值为1或0的哈希值,以说明哪个是第一个,如:
$VAR1 = {
'first' => {
'second' => 1,
'third' => 1,
},
'second' => {
'first' => 0,
'third' => 1,
},
'third' => {
'first' => 0,
'second' => 0,
'fourth' …Run Code Online (Sandbox Code Playgroud)