Utilities: Modernize output and comparison in the sort utility

Use the comparison operator of AK/String instead of strcmp(3) and
replace fput* by outln.
This commit is contained in:
Ralf Donau 2021-09-04 22:31:29 +02:00 committed by Andreas Kling
parent 7d8e036e26
commit 4f0e2f2584
Notes: sideshowbarker 2024-07-18 04:44:40 +09:00

View file

@ -37,13 +37,10 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
lines.append({ buffer, AK::ShouldChomp::Chomp });
}
quick_sort(lines, [](auto& a, auto& b) {
return strcmp(a.characters(), b.characters()) < 0;
});
quick_sort(lines);
for (auto& line : lines) {
fputs(line.characters(), stdout);
fputc('\n', stdout);
outln("{}", line);
}
return 0;