sort: true
works
sort: { a, b -> a <=> b }
, which looks to be simply the explicit version of true
, fails with ERROR ~ Invalid method invocation
. So, I’m missing some syntax that makes the closure understandable to collectFile(sort: )
A custom sorting criteria can be specified with a Closure or a Comparator object.
/*
Version: 24.04.4 build 5917
Created: 01-08-2024 07:05 UTC
System: Linux 5.14.0-362.24.1.el9_3.x86_64
Runtime: Groovy 4.0.21 on OpenJDK 64-Bit Server VM 11.0.22+7-LTS
Encoding: UTF-8 (UTF-8)
*/
workflow {
channel.of(
"A1,0000,c0",
"A1,0000,c1",
"A1,0000,c2",
"A1,0000,c3",
"A1,0000,c4",
"B1,0000,c0",
"B1,0000,c1",
"B1,0000,c2",
"B1,0000,c3",
"B1,0000,c4",
"A1,0001,c0",
"A1,0001,c1",
"A1,0001,c2",
"B1,0001,c3",
"B1,0001,c4",
)
.toSortedList { a, b -> a <=> b } .flatten().view()
.collectFile(seed: "WELL,TILE,CYCLE", name: 'tile-well-list.csv', newLine: true,
sort:
// true // works
{ a, b -> a <=> b } // similar to https://www.nextflow.io/docs/latest/operator.html#tosortedlist
// and demonstrated above
// ERROR ~ Invalid method invocation `doCall` with arguments: A1,0001,c0 (java.lang.String) on _closure5 type
)
.view().splitCsv().view()
}