RosettaCodeData/Task/Optional-parameters/Phix/optional-parameters-3.phix

23 lines
675 B
Plaintext

integer sortcol = 0
integer sortdir = 1
function by_column(integer i, integer j)
return sortdir*compare(data[i][sortcol],data[j][sortcol])
end function
sequence tags = tagset(table_size) -- {1,2,..table_size}
function click_cb(Ihandle self, integer l, integer c, atom pStatus)
string sortc
...
sortc = sprintf("SORTSIGN%d",c)
sortdir = iff(IupGetAttribute(self,sortc)="DOWN"?-1:1)
IupSetAttribute(self,sortc,iff(sortdir=-1?"UP":"DOWN"))
sortcol = c
tags = custom_sort(routine_id("by_column"),tags)
function value_cb(Ihandle /*self*/, integer l, integer c)
l = tags[l]
return data[l][c]
end function