pash
pash copied to clipboard
Add C++ aggregator for `sort`
I started implementing the C++ aggregator for FreeBSD that corresponds to sort
. ~It doesn't support any flags and doesn't pass the unit test yet.~ It passes the basic unit test now (the version with no flags). The flags that are yet to be implemented:
- [ ]
u
. Sort in unique mode - [ ]
n
. Sort treating lines as numbers (remember about leading minus, decimal point or comma and thousands separator) - [ ]
r
. Reverse sort direction - [ ]
k[...]
. Sort by columns - [ ]
f
.toupper
before sorting - [ ]
b
. Ignore whitespace at the beginning of a line - [ ]
d
. "consider only blanks and alphanumeric characters"
There are also some other options, but they don't seem as easy to implement at first glance. All of the options above are also supported in FreeBSD and are the same. One thing that could be tricky is dealing with locales.
I also realized that for some reason libdash
updated by itself. I'm not sure if this is wanted or not.
@nvasilakis Now the simple sort
aggregator works. It passes the unit test. It is basically the merge step from mergesort. Implementing support for sort
flags should be straightforward, but will take some time due to their amount. I plan to do this using either higher-order functions or polymorphism. I will see what will be easier and more performant.
I updated the main comment with some notes and an option to-do list for better organization.
Hi @janekb04 are you planning on completing this so that we merge it into mainline?