Comment

Comment by gatestone

How is it complicated to sort a list? The only challenge is to provide a corresponding swap function for your list (or for any ordinal "collection" you need), like in this example for arrays, when it is trivial:

func (s Organs) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

http://golang.org/pkg/sort/#example_Interface

Also note two things:

- This is the efficient and type safe way to handle polymorphism in Go

- The standard packages documentation is very nice with live, runnable examples

parent gatestone 13 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton