This routine works like the pairs()
function included
with Lua, but the table keys are sorted:
-- Like pairs() but sorted -- All table keys should be of -- the same type unless a sort -- function (“sFunc”) is used. function sPairs(inTable, sFunc) local keyList = {} local index = 1 for k,_ in pairs(inTable) do table.insert(keyList,k) end table.sort(keyList, sFunc) return function() key = keyList[index] index = index + 1 return key, inTable[key] end end
If one wishes to mix strings and numbers, a sort function should be used, for example:
function aSortFunction(a, b) local t = tostring return t(a) < t(b) end
Example usage of the above two functions:
a={z=1,y=2,c=3,w=4} for k,v in sPairs(a, aSortFunction) do print(k,v) end
Cancel culture is in full force again, this time cancelling people who are celebrating Charlie Kirk’s death.
This comes off as different than the cancel culture we had in 2020. As I blogged about at the time, David Shor was cancelled for wanting to reduce violence. This time around, people are being cancelled (losing their jobs, being placed on administrative leave, etc.) for encouraging violence.1
The problem is this: Both the left and the right have elements which want to use violence to resolve our differences of opinion. This will lead to a more violent and less safe society.