Re: [go-nuts] Re: sort string slice like it contains key,val

2021-03-14 Thread Vasiliy Tolstov
вс, 14 мар. 2021 г. в 01:38, 'Axel Wagner' via golang-nuts : > > One thing I would add is that you'll likely want to use the *Stable versions > of the sort functions, to make sure the order of equivalent elements does not > change. > Apart from that, the solution posted by Carla above with an add

Re: [go-nuts] Re: sort string slice like it contains key,val

2021-03-13 Thread 'Axel Wagner' via golang-nuts
One thing I would add is that you'll likely want to use the *Stable versions of the sort functions, to make sure the order of equivalent elements does not change. Apart from that, the solution posted by Carla above with an added step to remove duplicates seems like the best solution. On Sat, Mar 1

Re: [go-nuts] Re: sort string slice like it contains key,val

2021-03-13 Thread Vasiliy Tolstov
вс, 14 мар. 2021 г. в 01:10, Brian Candler : > > If I understand rightly, the values in the slice are to be interpreted (key, > value) pairs? In that case, the natural thing to me is to build a map. This > also takes care of "duplicate key, last value wins". You can then sort the > keys and c