Re: [go-nuts] sort string slice like it contains key,val
вс, 14 мар. 2021 г. в 00:41, Robert Engels : > > That wasn’t specified in the assignment :) =) As always after first stuff i need the second =) > > On Mar 13, 2021, at 2:59 PM, Levieux Michel wrote: > > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element, which I'd say is not > *too bad*, what are your performance constraints? > > Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : >> >> Looks fine =) But how to remove duplicates? >> I'm found this stuff >> https://github.com/campoy/unique/blob/master/unique.go but as i >> understand it needs to adapt to my case =) >> >> сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts >> : >> > >> > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> >> >> the sort package from the stdlib, it contains an interface that you can >> >> easily implement for such problematics :) >> > >> > >> > Like this: https://play.golang.org/p/eoLJ2aVAWkD >> > >> > >> > -- >> > 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. >> >> >> >> -- >> 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/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%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/CAL4P9zwK5vh1cwmq0yrCVuJsNCg0WXqfhZuXg%2BgV2MTFO--KvQ%40mail.gmail.com. -- 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/CACaajQuqPZyUt1QWU8T9O46JcgUSq72%2B_FSajxeQWrV5SGGHZw%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
I think that remove after sort is good for me, thanks сб, 13 мар. 2021 г. в 23:59, Levieux Michel : > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element, which I'd say is not > *too bad*, what are your performance constraints? > > Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : >> >> Looks fine =) But how to remove duplicates? >> I'm found this stuff >> https://github.com/campoy/unique/blob/master/unique.go but as i >> understand it needs to adapt to my case =) >> >> сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts >> : >> > >> > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> >> >> the sort package from the stdlib, it contains an interface that you can >> >> easily implement for such problematics :) >> > >> > >> > Like this: https://play.golang.org/p/eoLJ2aVAWkD >> > >> > >> > -- >> > 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. >> >> >> >> -- >> 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/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%40mail.gmail.com. -- 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/CACaajQsbvy9ofxGhSfOoBBQNxtPQnXxZtm2kfiEWyZ4goiwwtw%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
That wasn’t specified in the assignment :) > On Mar 13, 2021, at 2:59 PM, Levieux Michel wrote: > > > Your need is not only to sort your data elements then..? > Using the previously advised solution you can just range the slice *after* > you sort it, so you can just check for the next element, which I'd say is not > *too bad*, what are your performance constraints? > >> Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : >> Looks fine =) But how to remove duplicates? >> I'm found this stuff >> https://github.com/campoy/unique/blob/master/unique.go but as i >> understand it needs to adapt to my case =) >> >> сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts >> : >> > >> > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> >> >> the sort package from the stdlib, it contains an interface that you can >> >> easily implement for such problematics :) >> > >> > >> > Like this: https://play.golang.org/p/eoLJ2aVAWkD >> > >> > >> > -- >> > 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. >> >> >> >> -- >> 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/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%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/CAL4P9zwK5vh1cwmq0yrCVuJsNCg0WXqfhZuXg%2BgV2MTFO--KvQ%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/39A64340-E93D-48E3-A66F-1BB7923B027E%40ix.netcom.com.
Re: [go-nuts] sort string slice like it contains key,val
Your need is not only to sort your data elements then..? Using the previously advised solution you can just range the slice *after* you sort it, so you can just check for the next element, which I'd say is not *too bad*, what are your performance constraints? Le sam. 13 mars 2021 à 21:33, Vasiliy Tolstov a écrit : > Looks fine =) But how to remove duplicates? > I'm found this stuff > https://github.com/campoy/unique/blob/master/unique.go but as i > understand it needs to adapt to my case =) > > сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts > : > > > > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: > >> > >> the sort package from the stdlib, it contains an interface that you can > easily implement for such problematics :) > > > > > > Like this: https://play.golang.org/p/eoLJ2aVAWkD > > > > > > -- > > 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com > . > > > > -- > 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/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%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/CAL4P9zwK5vh1cwmq0yrCVuJsNCg0WXqfhZuXg%2BgV2MTFO--KvQ%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
Looks fine =) But how to remove duplicates? I'm found this stuff https://github.com/campoy/unique/blob/master/unique.go but as i understand it needs to adapt to my case =) сб, 13 мар. 2021 г. в 16:47, 'Carla Pfaff' via golang-nuts : > > On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: >> >> the sort package from the stdlib, it contains an interface that you can >> easily implement for such problematics :) > > > Like this: https://play.golang.org/p/eoLJ2aVAWkD > > > -- > 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com. -- 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/CACaajQt22G7JxY3yGiMt_H37aSkBatz3W6FZF90Gv90Uo0zTUA%40mail.gmail.com.
Re: [go-nuts] sort string slice like it contains key,val
On Saturday, 13 March 2021 at 14:44:05 UTC+1 mlevi...@gmail.com wrote: > the sort package from the stdlib, it contains an interface that you can > easily implement for such problematics :) > Like this: https://play.golang.org/p/eoLJ2aVAWkD -- 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/b8caea5d-fc98-41cf-85aa-b1526105840bn%40googlegroups.com.
Re: [go-nuts] sort string slice like it contains key,val
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 a écrit : > Hi! > I'm stuck at sorting stuff like > > []string{"xxxkey","xxxval","zzzkey","zzzval","aaakey","aaaval","zzzkey","val"} > i need to get after sorting something like > []string{"aaakey","aaaval", "xxxkey","xxxval","zzzkey","val"} > > 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.