summaryrefslogtreecommitdiff
path: root/include/human_sort.hpp
AgeCommit message (Collapse)AuthorFilesLines
2024-01-09Fix spelling mistakesEd Tanous1-1/+1
These were found with: codespell -w $(git ls-files | grep "\.[hc]\(pp\)\?$") At some point in the future, we might want to get this enabled in CI. Change-Id: Iccb57b2adfd06a2e177e99db2923fe4e8e329118 Signed-off-by: Ed Tanous <ed@tanous.net>
2023-05-11human-sort: fix clang-tidy warnings about pointer arithmeticPatrick Williams1-6/+6
Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Change-Id: I8122bfffaac469ee551c72632b671e8644a4da44
2023-05-11clang-format: copy latest and re-formatPatrick Williams1-1/+0
clang-format-16 has some backwards incompatible changes that require additional settings for best compatibility and re-running the formatter. Copy the latest .clang-format from the docs repository and reformat the repository. Change-Id: I75f89d2959b0f1338c20d72ad669fbdc1d720835 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2023-02-24Pass string views by valueEd Tanous1-2/+1
string_view should always be passed by value; This commit is a sed replace of the code to make all string_views pass by value, per general coding guidelines[1]. [1] https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/ Tested: Code compiles. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I55b342a29a0fbfce0a4ed9ea63db6014d03b134c
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