DEV Community

Discussion on: Easy Sorting in Go

Collapse
 
rxliuli profile image
rxliuli

This is not particularly simple, at least, compared to the sort function in js

[3,2,1].sort((a, b) => a - b)

Collapse
 
jpoly1219 profile image
Jacob Kim

There definitely is a lot more "prep" work to do in order to use sort.Sort(). I still like the idea of sorting custom types instead of just arrays. Plus, it's a really nice way to see how these sorts work under the hood in Go. I guess Go and Javascript work in different ways :P

That being said, for simple arrays, you could just use the three functions listed above such as Ints, Float64s, or Strings!