Anonymous user
Optional parameters: Difference between revisions
m
→{{header|AutoHotkey}}: Minor indentation and casing edit
(+ AutoHotkey) |
m (→{{header|AutoHotkey}}: Minor indentation and casing edit) |
||
Line 15:
Do not implement a sorting algorithm; this task is about the interface. If you can't use a built-in sort routine, just omit the implementation (with a comment).
=={{header|AutoHotkey}}==
built in support for table sorting is available through the standard
<lang AutoHotkey>
sort_table("Text", column := 2, reverse := 1) ; lexicographic sort
sort_table("Integer", column := 2, reverse := 1) ; numerical sort
Return
start:
Gui, Add, ListView, r20 w200, 1|2|3
data =
(
1,2,3
b,q,z
c,z,z
)
{
LV_Add(row, row1, row2, row3)▼
}
LV_ModifyCol(50) ; Auto-size columns▼
Gui, Show▼
Return
sort_table(ordering = "Text", column = 0, reverse = 0)▼
▲Loop, parse, data, `n
{
▲ stringsplit, row, A_LoopField, `,
▲ LV_Add(row, row1, row2, row3)
LV_ModifyCol(column, "sort" . desc . " " . ordering) ▼
}
▲LV_ModifyCol(50) ; Auto-size columns
▲Gui, Show
GuiClose:
ExitApp
</lang>▼
▲sort_table(ordering = "Text", column = 0, reverse = 0)
▲ if reverse
▲ desc = desc
▲ LV_ModifyCol(column, "sort" . desc . " " . ordering)
▲</lang>
=={{header|BASIC}}==
{{works with|Beta BASIC|3.0}}<br>
|