diff --git a/README.md b/README.md
index 680349d..231a60e 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ sudo curl -s "https://raw.githubusercontent.com/miguelmota/cointop/master/instal
$ cointop
```
-### Cointop commands
+### Shortcuts
List of default shortcuts:
@@ -78,6 +78,8 @@ Key|Action
Ctrl+p|Go to previous page (vim style)
Ctrl+r|Force refresh
Ctrl+u|Jump page up (vim style)
+Alt+↑|Sort current column in ascending order
+Alt+↓|Sort current column in descending order
Alt+←|Sort column to the left
Alt+→|Sort column to the right
F1|Show help|
diff --git a/cointop/help.go b/cointop/help.go
index a1bc2d8..961fc49 100644
--- a/cointop/help.go
+++ b/cointop/help.go
@@ -12,5 +12,5 @@ func (ct *Cointop) openHelp(g *gocui.Gui, v *gocui.View) error {
}
func (ct *Cointop) helpLink() string {
- return "https://github.com/miguelmota/cointop"
+ return "https://github.com/miguelmota/cointop#shortcuts"
}
diff --git a/cointop/keybindings.go b/cointop/keybindings.go
index 810c113..4f097b6 100644
--- a/cointop/keybindings.go
+++ b/cointop/keybindings.go
@@ -51,6 +51,8 @@ func (ct *Cointop) keybindings(g *gocui.Gui) error {
ct.setKeybinding(gocui.KeyCtrlP, ct.prevPage)
ct.setKeybinding(gocui.KeyCtrlR, ct.refresh)
ct.setKeybinding(gocui.KeyCtrlU, ct.pageUp)
+ ct.setKeybindingMod(gocui.KeyArrowUp, gocui.ModAlt, ct.sortAsc)
+ ct.setKeybindingMod(gocui.KeyArrowDown, gocui.ModAlt, ct.sortDesc)
ct.setKeybindingMod(gocui.KeyArrowLeft, gocui.ModAlt, ct.sortPrevCol)
ct.setKeybindingMod(gocui.KeyArrowRight, gocui.ModAlt, ct.sortNextCol)
ct.setKeybinding(gocui.KeyF1, ct.openHelp)
diff --git a/cointop/sort.go b/cointop/sort.go
index aff6de7..6f6ebc7 100644
--- a/cointop/sort.go
+++ b/cointop/sort.go
@@ -78,13 +78,26 @@ func (ct *Cointop) sortfn(sortby string, desc bool) func(g *gocui.Gui, v *gocui.
}
}
-func (ct *Cointop) getSortColIndex() int {
- for i, col := range colorder {
- if ct.sortby == col {
- return i
- }
- }
- return 0
+func (ct *Cointop) sortAsc(g *gocui.Gui, v *gocui.View) error {
+ ct.sortdesc = false
+ ct.sort(ct.sortby, ct.sortdesc, ct.coins)
+ ct.Update(func() {
+ ct.tableview.Clear()
+ ct.updateTable()
+ })
+ ct.rowChanged()
+ return nil
+}
+
+func (ct *Cointop) sortDesc(g *gocui.Gui, v *gocui.View) error {
+ ct.sortdesc = true
+ ct.sort(ct.sortby, ct.sortdesc, ct.coins)
+ ct.Update(func() {
+ ct.tableview.Clear()
+ ct.updateTable()
+ })
+ ct.rowChanged()
+ return nil
}
func (ct *Cointop) sortPrevCol(g *gocui.Gui, v *gocui.View) error {
@@ -121,3 +134,12 @@ func (ct *Cointop) sortNextCol(g *gocui.Gui, v *gocui.View) error {
ct.rowChanged()
return nil
}
+
+func (ct *Cointop) getSortColIndex() int {
+ for i, col := range colorder {
+ if ct.sortby == col {
+ return i
+ }
+ }
+ return 0
+}