pash icon indicating copy to clipboard operation
pash copied to clipboard

Add C++ aggregator for `sort`

Open janekb04 opened this issue 3 years ago • 4 comments

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.

janekb04 avatar Oct 05 '21 14:10 janekb04

I also realized that for some reason libdash updated by itself. I'm not sure if this is wanted or not.

janekb04 avatar Oct 05 '21 14:10 janekb04

@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.

janekb04 avatar Oct 05 '21 17:10 janekb04

I updated the main comment with some notes and an option to-do list for better organization.

janekb04 avatar Oct 05 '21 18:10 janekb04

Hi @janekb04 are you planning on completing this so that we merge it into mainline?

nvasilakis avatar Mar 11 '22 16:03 nvasilakis