summaryrefslogtreecommitdiff
path: root/include/human_sort.hpp
AgeCommit message (Collapse)AuthorFilesLines
2022-07-23test treewide: iwyuNan Zhou1-0/+1
These changes are done by running iwyu manually under clang14. Suppressed some obvious impl or details headers. Kept the recommended public headers. IWYU can increase readability, make maintenance easier, and avoid errors in some cases. See details in https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/WhyIWYU.md. This commit also uses its best effort to correct obvious errors through iwyu pragma. See reference here: https://github.com/include-what-you-use/include-what-you-use#how-to-correct-iwyu-mistakes Tested: unit test passed. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I983b6f75601707cbb0f2f04546c3362ff4ba7fee
2022-01-28Simplify human sortEd Tanous1-46/+41
Clang-tidy correctly noted that this method was overly complex and could be simplified. This commit does exactly that. Tested: Unit tests run and passing. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ia225f0d8cc5942f776bc8d5b48ca91de40596451
2022-01-19Include what you useEd Tanous1-2/+0
Do a partial update from the include what you use tool. While ideally we'd be able to do this as part of CI, there's still quite a bit of noise in the output that requires manual intervention. Tested: Code compiles Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iaaeb7a9199f64b5d6913c3abab4779b252768ed8
2021-10-12Implement human sort utility functionEd Tanous1-0/+117
This commit implements the ability to sort lists of strings that might include numbers into "human" ordered lists. As an example of a problem this solves, imagine a system with 12 dimms, today std::sort would net you: Dimm1 Dimm11 Dimm12 Dimm2 Dimm3 ..... This method breaks apart that string and sorts them in a way humans would expect. This code is originally inspired by the algorithm defined here: http://www.davekoelle.com/alphanum.html. The site does include c++ code that is MIT licensed, but is significantly more complex than what is present in this commit. This commit also takes advantages in the form of std::string_view to deduplicate overloads, as well as other c++17 features. Tested: Unit tests pass Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iac54c2e0d9998d4d622d74049b1dd957e4b3ca75