hashicorp / hcat

Hashicorp Configuration and Templating library (hcat, pronounced hashicat)
Mozilla Public License 2.0
95 stars 12 forks source link

fix stable sorting (no more <=) #102

Closed eikenb closed 2 years ago

eikenb commented 2 years ago

The code previously used sort.Stable with the sorting interface. It mistakenly used <= in the Less comparisons where it should have been just <. This would 'break' stable sort in that it wouldn't be stable (ie. sort order could change between calls) with 2 equal values.

This replaces the <= with < while also converting the code to use the newer, and more appropriate, sort.StableSlice()... which uses a function instead of the interface.