fix for TopPipe with duplicate values
Merge pull request #2332 from jexp/top-n-fix

fix for TopPipe with duplicate values