mrkn commented on a change in pull request #8612:
URL: https://github.com/apache/arrow/pull/8612#discussion_r519569356
##########
File path: cpp/src/arrow/compute/kernels/vector_sort.cc
##########
@@ -125,35 +128,43 @@ class CompareSorter {
std::stable_partition(indices_begin, indices_end,
[&values](uint64_t ind) { return
!values.IsNull(ind); });
}
- std::stable_sort(indices_begin, nulls_begin,
- [&values](uint64_t left, uint64_t right) {
- return values.GetView(left) < values.GetView(right);
- });
+ if (options.order == SortOrder::ASCENDING) {
+ std::stable_sort(indices_begin, nulls_begin,
+ [&values](uint64_t left, uint64_t right) {
+ return values.GetView(left) < values.GetView(right);
+ });
+ } else {
+ std::stable_sort(indices_begin, nulls_begin,
+ [&values](uint64_t left, uint64_t right) {
+ return values.GetView(left) > values.GetView(right);
Review comment:
This requires that all of `==`, `<`, and `>` are implemented in the
value type.
Instead, writing `right < left` here only requires `==` and `<`.
IMHO, requiring only `==` and `<` is better to support extension types in
the future.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]