Opened 20 years ago

Closed 20 years ago

Last modified 19 years ago

#57 closed defect (released)

Ought to allow choice of forward or reverse sorting on a value

Reported by: Olly Betts Owned by: Olly Betts
Priority: high Milestone:
Component: Library API Version: SVN trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Operating System: All

Description

Enquire::set_sort_forward() only affects which order document ids are sorted in. Sadly there's currently no way to affect the ordering used when sorting on a value.

The original plan was to allow the user to specify the sorting by subclassing, but we were concerned that a virtual method dispatch for every comparison might add an appreciable overhead as the compare can be called a lot. So we left it with the plan to try it and see at some point, which hasn't yet happened.

I suspect (having used C++ a lot more now) that the virtual method dispatch overhead wouldn't be a problem. But it could still be a problem if you are using the bindings and tried to write your sort function in (say) Python because there'd be all the glue code to call from C++ to Python for each comparison.

But the alternative is to have a whole slew of API methods to allow the user to control sorting in every way which they might reasonably want to be able to. So I've punted on this issue whenever I've thought about it recently.

Perhaps allowing a user provided sort function with some standard parameterised versions is a good approach. That means the sorting API is neatly separated into its own class hierarchy. And you can usually avoid the need to write one in the scripting language - you just specify suitable parameters to an existing C++ class. And for more exotic sorting requirements, you can write your own from scratch.

Change History (4)

comment:1 by Olly Betts, 20 years ago

Component: otherLibrary API
op_sys: otherAll
rep_platform: OtherAll
Status: newassigned
Version: otherCVS HEAD

comment:2 by Olly Betts, 20 years ago

Resolution: fixed
Status: assignedclosed

comment:3 by Olly Betts, 20 years ago

Fixed in SVN HEAD.

comment:4 by Olly Betts, 20 years ago

Operating System: All
Resolution: fixedreleased

Fixed in 0.9.0

Note: See TracTickets for help on using tickets.