Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Use sort.SliceStable to ensure stability
Browse files Browse the repository at this point in the history
Without this, a file that contains two lines that are identical when viewed
case-insensitively can end up flapping between omegasort runs.
  • Loading branch information
autarch committed Dec 29, 2020
1 parent c394dff commit 0fce38c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Replace file renaming with copying to handle the case where the temp file we
sort into and the original file are not on the same partition.

* Fix bug where sorting wasn't stable in the presence of two
case-insensitively identical lines (and possibly other similar scenarious)>


## 0.0.3 - 2020-12-27

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func (o *omegasort) run() error {
return nil
}

sort.Slice(lines, sorter)
sort.SliceStable(lines, sorter)
if *errRef != nil {
return *errRef
}
Expand Down

0 comments on commit 0fce38c

Please sign in to comment.