joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016
12:55 PM
Documentation semantic question
I'm looking into array sorting of Associative Arrays and when I arrived at this page https://sdkdocs.roku.com/display/sdkdoc/ifArraySort
I became concerned that it says it's implemented by roArray but not by roAssociativeArray.
But it actually does have the function for sorting AAs - should the page be updated to say that this is also implemented by roAssociativeArray?
thanks in advance.
I became concerned that it says it's implemented by roArray but not by roAssociativeArray.
But it actually does have the function for sorting AAs - should the page be updated to say that this is also implemented by roAssociativeArray?
thanks in advance.
aspiring
3 REPLIES 3


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016
02:18 PM
Re: Documentation semantic question
"joetesta" wrote:
I'm looking into array sorting of Associative Arrays and when I arrived at this page https://sdkdocs.roku.com/display/sdkdoc/ifArraySort
I became concerned that it says it's implemented by roArray but not by roAssociativeArray.
But it actually does have the function for sorting AAs - should the page be updated to say that this is also implemented by roAssociativeArray?
thanks in advance.
Arrays are sortable, associative arrays are not.
You can sort an array *of* associative arrays, but you are modifying the array itself, i.e. the order of items, and not modifying the array item values themselves.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2016
02:39 PM
Re: Documentation semantic question
When people speak - informally - about "sorting of dictionaries (assoc.arrays)", in my experience we tend to mean accessing/enumerating the dictionary in particular order - either by order of keys or order of values.
Now, roAA have .keys() method that returns array of the keys, pre-sorted.
OTOH, there is no .values() method...
PS. I thought i'll illustrate,
Now, roAA have .keys() method that returns array of the keys, pre-sorted.
OTOH, there is no .values() method...
PS. I thought i'll illustrate,
'for keys'
for each key in myAA.keys(): 'already sorted, haha!'
do_the_due(key, myAA[key])
next
'for values - invert the dictionary'
inv_aa = {}
for each key in myAA:
val = myAA[key]
bucket = inv_aa[val]: if bucket=invalid then bucket = []: inv_aa[val] = bucket
bucket.push(key)
next
for each vals in inv_aa:
for each val in vals:
do_the_due(vals[val], val)
next
next
joetesta
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2016
02:17 PM
Re: Documentation semantic question
You're right, I was hoping to sort on the keys and twisting my brain trying to figure out how to change my Associative Array so that the keys became sortable fields.
Ha - thanks again, yesterday I found the `.keys()` solution you'd posted earlier EnTerr, you are the best!!
-Joe
Ha - thanks again, yesterday I found the `.keys()` solution you'd posted earlier EnTerr, you are the best!!
-Joe
aspiring