|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Feb 15, 2014 12:13 pm
Sorting DBvar |
A have a chart of items i have compiled with their various High and Low values marked out to form a range
I would like them displayed in ascending order, by @var.%i.Low and in the event of a tie, by @var.%i.High
I was using this to display at the moment
#FORALL %dbkeys(fishDiff) {#SAY {%format("&-25s &4d -&4d", %i, @fishDiff.%i.Low, @fishDiff.%i.High)}} |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sat Feb 15, 2014 9:00 pm |
If you don't mind using Lua:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<alias name="showfish" language="Lua">
<value>local t = {}
for k, v in pairs(zs.var.fishDiff) do
table.insert(t, {Key = k, Low = v.Low, High = v.High})
end
table.sort(t, function(a, b)
if a.Low == b.Low then
return a.High <= b.High
else
return a.Low <= b.Low
end
end)
for i, v in ipairs(t) do
print(string.format("%-25s %4d -%4d", v.Key, v.Low, v.High))
end</value>
</alias>
</cmud> |
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Feb 15, 2014 9:13 pm |
File: . Line: 10 Col: 20 Error: Invalid element name: "
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Sun Feb 16, 2014 6:54 pm |
Meh, copy/paste it into an alias manually. The forum breaks the xml parsing for < and >, I don't remember how to work around that offhand.
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Mon Feb 17, 2014 7:32 am |
Attempt to index local 'b' (a nil value) (line 6)
Stack trace:
[string "code"]:6:in a Lua function
[C]:-1:in function "sort"
[string "code"]:5:in main chunk" |
|
_________________ Discord: Shalimarwildcat |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Sat Feb 22, 2014 2:36 pm |
Ever figure out the error message so i can get this working?
I don't know lua. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|