View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000366 | LDMud | Efuns | public | 2005-02-20 11:49 | 2005-02-20 11:58 |
Reporter | bubbs | Assigned To | |||
Priority | normal | Severity | feature | Reproducibility | always |
Status | new | Resolution | open | ||
Summary | 0000366: sort() efun | ||||
Description | Implement a mapping aware sort() efun. sort() would sort arrays and mappings, but always return an array. In the case of arrays, it would act like sort_array(). In the case of mappings, if no index is specified, then sort the mapping keys. Alternatively, specify an index to sort on mapping values. Optionally, use #'> as the default sorting function. | ||||
Additional Information | sort(mixed *array) - would return sort_array(array, #'>) sort(mixed *array, string|closure func, ...) - would return sort_array(array, func, ...) sort(mapping mapp) - would return sort_array(m_indices(mapp), #'>) sort(mapping mapp, string|closure func, ...) - would return sort_array(m_indices(mapp), func, ...) sort(mapping mapp, int index) - would return the keys of the mapping mapp, ordered by: ( mapp[key1, index] > mapp[key2, index] ). sort(mapping mapp, int index, string|closure func, ...) - would return the keys of the mapping mapp, ordered by: funcall(func, mapp[key1, index], mapp[key2, index], ... ). Effectively, map(sort(mapp, index, func...), mapp) == sort(m_values(mapp, index), func...) | ||||
Tags | No tags attached. | ||||
External Data (URL) | |||||
|
Correction: Effectively, map(sort(mapp, index, func...), mapp) == sort(m_values(mapp, index), func...) Should be: Effectively, map(sort(mapp, index, func...), mapp, index) == sort_array(m_values(mapp, index), func...) Except map(mixed *, mapping, int) doesn't work - see other issue. Additionally, I should be clear that sort(mapping, ...) ALWAYS returns the keys of the mapping. |