"Swap" and "Less", but you cannot define them over an slice. Could I define
these operations on the slice type?
If I cannot define them on the slice type, I have to create a new type that
is a slice of my struct. Is there any better approach?
When I receive an Slice of my struct (not the sort-able type, but a simple
slice) I can "transform" it into my sort-able type and sort it.
I have created an example here: http://play.golang.org/p/glmJVz7FTd
But for me it is hard to accept I have to create a new type and a new
variable in order to sort the slice. I expected to be able to tell the
compiler: "Please treat this variable that holds an slice of struct-X, as
if it were this sort-able type that is a slice of struct-X".
I would love to be able to write something like:
Ain't there any other (more idiomatic) way to do this?
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/groups/opt_out.