By adding 'sortable' to the database column defs, you can make it sortable:

case 'database columns':
$columns['amount'] = array(
'type' => 'int',
'length' => 13,
'not null' => TRUE,
'default' => 0,
'unsigned' => FALSE,
'sortable' => TRUE,
);
$columns['currency'] = array('type' => 'varchar', 'length' => 3, 'sortable' => TRUE);
return $columns;

Comments

wim leers’s picture

But sorting amounts with different currencies doesn't make much sense...

M. P.’s picture

I use your module - by the way, thank you very much - with only 1 currency, because of its powerfull formatting options and separator treatment.
So, sometimes sorting could make sense.

wim leers’s picture

Title: sortable in views » Sort by amount (but not taking the currencies into account)

That's true. But I don't like half-baked solutions... hence I was postponing this. Since you seem to be able to write code, could you please verify the code that hamidrj posted?

M. P.’s picture

hamidrj's code works well, like expected.
NOTE for "updaters": If you have already existing money fields, they won't get "sortable", of course.
You have to create new ones or fidling with the database - which I wouldn't recommend.

wim leers’s picture

Assigned: Unassigned » wim leers

Committed. Thanks!

wim leers’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.