Hi,

You should take a look at the sort package from the stdlib, it contains an
interface that you can easily implement for such problematics :)

Hope this helps!

Le sam. 13 mars 2021 à 14:37, Vasiliy Tolstov <v.tols...@selfip.ru> a
écrit :

> Hi!
> I'm stuck at sorting stuff like
>
> []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","ggggval"}
> i need to get after sorting something like
> []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","ggggval"}
>
> So i'm sort by "key" and if key is duplicated - last wins.
> Mostly i want to avoid creating helper slices that contains keys and
> vals dedicated, does it possible to do sorting only by swapping
> "key/val" ?
>
> --
> Vasiliy Tolstov,
> e-mail: v.tols...@selfip.ru
>
> --
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/CACaajQt82U878secmTSPaFW85a%3DWA20-vF%2BsPub%2B_w3i%3DohtEA%40mail.gmail.com
> .
>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAL4P9zxtGtLHVv-ujZ9c4Q0ButzobB78KZr3e5%3D-ucuP8curyQ%40mail.gmail.com.

Reply via email to