SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-31-2009, 08:39 AM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
How to sort Elements within a Group using a Method?

Gents,

I have a grouping that looks like this:

Code:
key1
  Item1, Item2, Item3, ...
key2
  Item1, Item2, Item3, ...
I need to sort all Items (for all keys) according to the result of a Method that requires several variables and returns a string. Like this:
Code:
Text = Method(Var1, Item, Var3)
I thought I could use SortLexical() but I am having trouble figuring out how to pass the correct parameters to the Method.

Any help would be greatly appreciated.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
  #2  
Old 10-31-2009, 10:53 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
By "grouping" you mean the result of a call to GroupByMethod()? That's actually a java.util.Map.

So you're saying you want the Map keys sorted into some order? Or you don't care about the key order, but you want the items under each key sorted? In the latter case, sort the original array or list before calling GroupByMethod(), and it will preserve the relative ordering of the items in each subgroup.

The method you pass to Sort() or SortLexical() must have the signature

int Method(item1, item2 [, ... ] )

As the docs indicate, if you pass in extra arguments to Sort(), they'll be pass through to the method like so:

Sort(data, descending, "Method", x, y, z, ...)
Method(item1, item2, x, y, z, ...)

If your method doesn't match that signature, you'll need to write a wrapper function for it in Java that does.

In case it's not clear from the docs, the difference between Sort() and SortLexical() is that Sort() sorts items according to their actual type, whereas SortLexical() always sorts them as strings. So if you apply SortLexical() to a list of integers, for instance, the result will be along the lines of 1, 10, 11, 12, ..., 2, 20, 21, 21, ..., etc. Unless you specifically want that, use Sort() instead of SortLexical().
__________________
-- Greg
Reply With Quote
  #3  
Old 10-31-2009, 12:57 PM
tmiranda's Avatar
tmiranda tmiranda is offline
SageTVaholic
 
Join Date: Jul 2005
Location: Central Florida, USA
Posts: 5,851
Greg,

The grouping is made by calling new_java_util_HashMap and then AddToGrouping() so I suppose I have a Map? (Sorry my java terminology is so poor.)

I figured out how to sort the keys but I haven't figured out how to sort the Items for each key. When I call AddToGrouping() the Items are in no particular order. Unfortunately for me the Method I need to use to sort them does not have the right signature and writing a wrapper is currently beyond my skills.

But I learned programming in the dark ages and do remember how to code a bubble sort

I do need to bite the bullet and learn how to make .jar files that I can use from within studio. What's your recommendation for the development environment?

Thanks for the tip on Sort() vs. SortLexical(). I already figured that one out, the hard way.

Tom
__________________

Sage Server: 8th gen Intel based system w/32GB RAM running Ubuntu Linux, HDHomeRun Prime with cable card for recording. Runs headless. Accessed via RD when necessary. Four HD-300 Extenders.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange chaning of elements inside grouping PLUCKYHD SageTV Studio 3 08-12-2009 12:07 PM
Viewing Photoshop Elements Catalog With MVP nwboater SageTV Customizations 20 12-23-2008 10:11 AM
can I group all recorded movies into a MOVIES group Deacon Crusher SageMC Custom Interface 5 06-05-2008 12:22 PM


All times are GMT -6. The time now is 06:06 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.