This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Sort table and make schedule from script
#4
Since you have [0] index in the table it is not treated as an array (index 1..n) so it cannot be sorted. You can convert it to array like this:
Code:
tbl_price = storage.get('NordPool_prices') -- Get prize from Nordpool
arr_price = {}

for _, row in pairs(tbl_price) do
  arr_price[ #arr_price + 1 ] = row
end

table.sort(arr_price, function(a, b) return a['price_total'] > b['price_total'] end)
log(arr_price)
Reply


Messages In This Thread
RE: Sort table and make schedule from script - by admin - 14.02.2022, 14:02

Forum Jump: