Re: [go-nuts] Sorting user defined collection in multiple ways

2017-07-21 Thread Jan Mercl
On Fri, Jul 21, 2017 at 3:17 PM  wrote:

> - I have user defined data structure called Employee with attributes
"age", name and sal. I want to write three different go functions that
sorts based on age, name and sal.

Are you sorting a slice? https://golang.org/pkg/sort/#Slice

-- 

-j

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Sorting user defined collection in multiple ways

2017-07-21 Thread srinik . kandula
Hi,
I have below requirement, could any one suggest on how i can achieve in go 
lang using https://golang.org/pkg/sort/.
- I have user defined data structure called Employee with attributes "age", 
name and sal.  I want to write three different go functions that sorts 
based on age, name and sal.
example:-
  sortEmployeeByAge(employeelist)
  sortEmployeeByName(employeelist)
  sortEmployeeBySal(employeelist)

Thanks,
Srinivas K

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.