Skip to content

Instantly share code, notes, and snippets.

@Phryxe
Last active February 11, 2019 09:32
Show Gist options
  • Save Phryxe/225a5ed619a9e648ab9ef1323d0e99bc to your computer and use it in GitHub Desktop.
Save Phryxe/225a5ed619a9e648ab9ef1323d0e99bc to your computer and use it in GitHub Desktop.
Red []
x: [
["Liza" "Smith" 1834 1891]
["Cynthia" "Lancaster" 1745 1800]
["Adam" "Goya" 1900 1949]
["Eric" "Anderson" 1802 1888]
["Sam" "Kennedy" 1899 1949]
]
update: func [][
f1a/text: x/1/1
f1b/text: x/1/2
f1c/text: to-string x/1/3
f1d/text: to-string x/1/4
f2a/text: x/2/1
f2b/text: x/2/2
f2c/text: to-string x/2/3
f2d/text: to-string x/2/4
f3a/text: x/3/1
f3b/text: x/3/2
f3c/text: to-string x/3/3
f3d/text: to-string x/3/4
f4a/text: x/4/1
f4b/text: x/4/2
f4c/text: to-string x/4/3
f4d/text: to-string x/4/4
f5a/text: x/5/1
f5b/text: x/5/2
f5c/text: to-string x/5/3
f5d/text: to-string x/5/4
]
t1c: true
t2c: true
t3c: true
t4c: true
click: func [face event][
if face = t1 [
either t1c [
t1c: false
sort x
]
[
t1c: true
sort/reverse x
]
update
]
if face = t2 [
either t2c [
t2c: false
sort/compare x function [a b][a/2 < b/2]
][
t2c: true
sort/compare x function [a b][a/2 > b/2]
]
update
]
if face = t3 [
either t3c [
t3c: false
sort/compare x function [a b][a/3 < b/3]
][
t3c: true
sort/compare x function [a b][a/3 > b/3]
]
update
]
if face = t4 [
either t4c [
t4c: false
sort/compare x function [a b][a/4 < b/4]
][
t4c: true
sort/compare x function [a b][a/4 > b/4]
]
update
]
]
view/tight [
title "Sort Fake Datagrid"
style f: field 100 ivory bold
style t: text 100 gold bold center on-down [click face event]
across
t1: t "First Name"
t2: t "Surname"
t3: t "Birth"
t4: t "Death"
return
f1a: f
f1b: f
f1c: f
f1d: f
return
f2a: f
f2b: f
f2c: f
f2d: f
return
f3a: f
f3b: f
f3c: f
f3d: f
return
f4a: f
f4b: f
f4c: f
f4d: f
return
f5a: f
f5b: f
f5c: f
f5d: f
do [update]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment