我有这样的格式:
user: "some_text"
我需要按user
按字母顺序对文件进行排序。问题是用户重复时我需要保持"some_text"
的位置。
例如:
Jack: "Daniel has an apple"
Daniel: "No"
Daniel: "Jack is a morun"
Daniel: "Alfa and beta"
John: "Blah blah blah"
我试过sort -t':' -k1,1
我得到了这个:
Daniel: "Alfa and beta"
Daniel: "Jack is a morun"
Daniel: "No"
Jack: "Daniel has an apple"
John: "Blah blah blah"
我需要:
Daniel: "No"
Daniel: "Jack is a morun"
Daniel: "Alfa and beta"
Jack: "Daniel has an apple"
John: "Blah blah blah"
答案 0 :(得分:2)
看看GNU sort的选项:
import import scala.concurrent.duration.DurationLong import scala.concurrent.{Await, Future} ... ... val setup = db.run(queries).foreach(_ => println("Done, schema created!)) Await.result(setup, 5L.seconds)
:通过禁用最后比较来稳定排序
-s
输出:
Daniel: "No" Daniel: "Jack is a morun" Daniel: "Alfa and beta" Jack: "Daniel has an apple" John: "Blah blah blah"