INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Smartlists: Including empty/zero values in sort order?  (Read 2039 times)

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Smartlists: Including empty/zero values in sort order?
« on: July 05, 2015, 01:32:09 pm »

It seems like I'm probably missing something obvious here, I just don't write smartlists very often.
Is there an easy way to include empty/zero values in the sort order in a smartlist?
 
For example if I want to create a playlist which plays tracks that I either haven't heard, or haven't listened to for a long time, I would sort by "Last Played"
 
Only the order I'm getting is:
Tracks played a long time ago >  tracks played recently > tracks which have never been played
 
The order I'm looking for would be:
Tracks which have never been played > tracks played a long time ago > tracks played recently
 
Is there any way to change this behavior, or perhaps sort by an expression? (it's easy enough to get the right order using: If(IsEmpty([Last Played,0]),0,[Last Played,0]))
I'd prefer not to create a new field just for this one smartlist.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5177
  • "Linux Merit Badge" Recipient
Re: Smartlists: Including empty/zero values in sort order?
« Reply #1 on: July 05, 2015, 01:49:38 pm »

For some reason uninitialized values always sort at the end of a sort (regardless of which direction it's in), which has been remarked on previously.  So, for example, if you sorted last played in descending order the smartlist would look "right" (most recent at the top, never played at the bottom), but the reverse always shows the behavior you're describing (whether sorting by plays, last played, or most other fields). 

There was another thread on this exact issue several months back, but I can't seem to find it now. I think the workaround offered in that thread was creating a custom field, unfortunately.
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Smartlists: Including empty/zero values in sort order?
« Reply #2 on: July 05, 2015, 02:54:38 pm »

Yeah, it's easy enough to do with a custom field, but I was hoping that there was a way to simply enter an expression into the smartlist editor to avoid it.
 
I already have too many custom fields that do one specific task, which I really need to clean out some time.
 
And it makes it difficult to share these playlists with people, since you have to describe how to create a new field, rather than providing a block of code to copy & paste into the smartlist editor.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8009
Re: Smartlists: Including empty/zero values in sort order?
« Reply #3 on: July 05, 2015, 04:24:14 pm »

You don't need a custom Library field to do your sort.  Just make an expression column in your Smart List with the IsEmpty expression you listed.  Then click that column and voila it sorts how you want.

I agree that you now can't share this smart list easily, but at least it's not a real field.  Just an on the fly field in a list.

Brian.
Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41990
  • Shoes gone again!
Re: Smartlists: Including empty/zero values in sort order?
« Reply #4 on: July 06, 2015, 08:19:20 am »

Only the order I'm getting is:
Tracks played a long time ago >  tracks played recently > tracks which have never been played

There's an option "Sort empty strings last" that is used the the files that have never been played.  You can choose to have them sort at the top or the bottom of the list.
Logged
Matt Ashland, JRiver Media Center

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Smartlists: Including empty/zero values in sort order?
« Reply #5 on: July 06, 2015, 11:04:13 am »

Would it be possible to set that on a per-smartlist basis? I wouldn't normally want that enabled, only for this one specific use-case.
 
Being able to sort by an expression would also solve this of course, and may have more uses.
Logged

mwillems

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 5177
  • "Linux Merit Badge" Recipient
Re: Smartlists: Including empty/zero values in sort order?
« Reply #6 on: July 06, 2015, 11:32:57 am »

Honestly, if we're adding options, can I suggest an option (maybe a third position for the existing sort option) to sort empty or null values as though they were zeros for numeric fields?  Obviously it doesn't make sense for alphabetical fields, but it seems like the intuitive behavior for numeric or date fields would be to sort the empties after the zeroes, or along with them.  It's a fairly common "how do I do this?" request (including this thread), so there's definitely a "felt need" for it.  For my part, I would enable that option globally and never look back.

It would help with library views too.  
Logged

6233638

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 5353
Re: Smartlists: Including empty/zero values in sort order?
« Reply #7 on: July 06, 2015, 01:27:15 pm »

That probably makes sense, unless anyone can think of an example where that would be sorted incorrectly.
Logged
Pages: [1]   Go Up