In scala, I am trying to sort the below sequence of sequence,
Seq(Seq(2,3,4),Seq(1),Seq(1,2),Seq(1,2),Seq(1,2,3),Seq(2,3),Seq(1,3,4),
Seq(2,3,4,5),Seq(2,3,5),Seq(3,4,6),Seq(3,4),Seq(3,4,5))
.sortWith((a,b)=>{
(a zip b).filterNot(x => (x._1==x._2 || x._1 > x._2)).size > b.size
})
Output required:
<br/>1
<br/>1, 2
<br/>1, 2
<br/>1, 2, 3
<br/>1, 3, 4
<br/>2, 3
<br/>2, 3, 4
<br/>2, 3, 4, 5
<br/>2, 3, 5
<br/>3,4
<br/>3,4,5
<br/>3,4,6
The pattern that I am looking for is similar to the following,
<br/>1
<br/>1,2
<br/>1,2,3
<br/>1,3,4
<br/>2,4
<br/>2,4,5
<br/>2,5,6,7
<br/>3
<br/>3,4
<br/>3,4,5
直接比较2个序列,但这很具有挑战性。
请帮助我解决该情况。