this is probably what you want:
func sortPluginTripletsByManufacturerAndPlugin(
plugins:consuming [Triplet<String>]) -> [Triplet<String>]
{
plugins.sort
{
($0.p0, $0.p2) < ($1.p0, $1.p2)
}
return plugins
}
i would also make Triplet<T>
a struct and not a class, unless you have a different reason for it to be a class.
the predicate of MutableCollection.sort(by:)
should return a boolean indicating if two elements are in ascending order, it should not return a sort key.
notes:
-
you should use
consuming
andsort
instead ofsorted
, until someone fixes this bug -
swift tuples always compare in lexicographical order, so you can just use
($0.p0, $0.p2) < ($1.p0, $1.p2)
as the predicate. you cannot return a sort key because tuples are notComparable
.