INTERACT FORUM

Please login or register.

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

Author Topic: Sort by "Number Plays"  (Read 2534 times)

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Sort by "Number Plays"
« on: February 21, 2015, 06:39:20 pm »

Hi, I would like to sort listed files by "Number of Plays", so as to have played files move to the end of the list for better control of which I've seen and which not...
Unfortunately this doesn't work, because files that were never played don't have a value in the "Number Plays" field. As a result, they are not taken into account and get sorted below the played files (instead above them).
I tried to work around the issue by entering a "0" into the field for unplayed files, but that's not working either (value remains 'void' = unpopulated)...

Any alternatives that will move unplayed files to the end of the list?

(NB: I removed "fails for unplayed files" from topic title to avoid outbreaks of laughter ;-)
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sort by "Number Plays"
« Reply #1 on: February 21, 2015, 10:40:05 pm »

Integer fields in MC, like [Number Plays], cannot store a null value.  All integer fields in MC "default" to zero (or, null is treated identically, in any case).  Zero is shown in the UI as though it is empty, but the field actually contains a zero.  This is because you'd rarely want to see a column full of zeros for values that are blank.

Read the Fields section of the Expression Language Article on the wiki for more details:
http://wiki.jriver.com/index.php/Media_Center_expression_language#Fields

Empty values sort last by default, but this can be disabled here:
Tools > Options > Tree & View > Sorting > Sort empty strings last

However, that impacts all sorting of empty strings in Media Center, you might not like the results.  I'd recommend instead that you explicitly create a reverse-sortable [Number Plays (Sortable)] field instead.  You can use this expression:

Code: [Select]
If(IsEmpty([Number Plays], 1),0,[Number Plays])
You don't even have to show this special field as a column in the View.  Just use it in the Sorting on your view (in the Set rules for file display search) when you need to use it.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Sort by "Number Plays"
« Reply #2 on: February 22, 2015, 08:10:56 am »

Quote
Empty values sort last by default, but this can be disabled here:
Tools > Options > Tree & View > Sorting > Sort empty strings last
Thanks a LOT! This option already did the trick...
Quote
However, that impacts all sorting of empty strings in Media Center, you might not like the results.
No problem, this setting should work fine in most environments (for who would sort by fields they don't use ;-)...

It should be said that this option is but one of many in the settings dialogue that I don't understand... (some meanings probably getting "lost in translation", namely to German ;-) -- although in this case the original "Sort empty strings last" isn't much clearer than its (backtranslated) German "Display empty entries last". The option might be rephrased to something more telling, e.g. "Ignore empty fields for sorting"...
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sort by "Number Plays"
« Reply #3 on: February 22, 2015, 09:26:01 am »

They're not ignored.  They're sorted to the bottom of the list.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Sort by "Number Plays"
« Reply #4 on: February 22, 2015, 12:44:56 pm »

They're not ignored.  They're sorted to the bottom of the list.

Depends how you define 'ignore' - I think if empty strings are sorted last, that means their 'null' value is not interpreted as such (hence is ignored in a way). Otherwise, when sorting by "Number Plays" (A-Z) null values should sort on top, which is what I meant to do...

Either way, thanks again for those useful insights!
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sort by "Number Plays"
« Reply #5 on: February 22, 2015, 03:48:51 pm »

No problem, this setting should work fine in most environments (for who would sort by fields they don't use ;-)...

It doesn't work for me at all, generally.  Because I often sort on fields that aren't universally filled.  When you have a sort like this one (which I use for basically all of my "music" views):

~sort=[Artist],[Album],[Disc #],[Track #],[Name]

[Artist] is essentially always filled, but [Album] isn't always ("junk tracks", singles, and B-sides for artists I don't particularly care about enough to bother getting them "just so").  If a particular track by an Artist doesn't have a filled [Album] value then it floats to the top of that particular artist's "section".  That makes me hunt through the junk more often to get to the stuff I usually want.

Same goes with tons of other situations, particularly for Video files.  And any time I sort on a field like [Keywords], as another example.

But, hey, if it works for you, that's why the option is there!  :)
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Sort by "Number Plays"
« Reply #6 on: February 22, 2015, 04:24:29 pm »

... If a particular track by an Artist doesn't have a filled [Album] value then it floats to the top of that particular artist's "section".

That's funny because I used to think sorting always works from top downwards (which is why empty values should always sort last, at least they do for me)... For example, in a list of videos where only some have the "Year" filled, these will always sort on top, thus making any other file without "Year" data move to the bottom.
For the same reason, I actually believe that "Sort empty strings last" option is only for fields that increment in 1-steps (such as "Number Plays", while I can't think of another, there may be ;-) -- assuming that any unpopulated fields are not sortable, thus ignored and moved to bottom, after all populated fields have been processed for sorting...
Put differently, I think sorting is also a means to have specified files appear on top of your list, followed by unspecified ones, assuming the latter are less important than the first. Doesn't that make sense?

NB: Put differently again, "sortable" files which contain data in those fields specified for sorting should take priority over "non sortable" files... For all I know that is the case.
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sort by "Number Plays"
« Reply #7 on: February 22, 2015, 06:15:40 pm »

All fields contain data in MC.  The data is just sometimes an empty string.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Sort by "Number Plays"
« Reply #8 on: February 22, 2015, 07:08:56 pm »

All fields contain data in MC.  The data is just sometimes an empty string.

Can we agree on 'value'? And that files not containing a 'value/string' in any one sorting criterion (= field is empty) will always sort below files that do? Call it a side effect of sorting -- the prior effect is to sort items by their values (such as 0 before 1, before 2, before 3, etc), the second to exclude or skip empty values in order to process existing values first (even though 'process' means simply to 'display' them in a specified order).

But well, if it's true what you reported earlier (
Quote
If a particular track by an Artist doesn't have a filled [Album] value then it floats to the top of that particular artist's "section".
) there must be something else at work... perhaps you had another, invisible field (auto) filled that moves the files to top?
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Sort by "Number Plays"
« Reply #9 on: February 22, 2015, 08:08:36 pm »

I really don't understand what you're talking about.  This isn't that difficult.  With the option discussed turned ON (the default) my files sort like this:



That's how I like it.  If you want Integer-type fields containing zeros (which are considered equivalent to empty strings) to sort to the top in an ascending list, then you have to disable that option, however (or use the alternate field I explained above).  That's fine.  If turning that option off works for you, then wonderful.  I don't like it because it makes my Albums sort like this:



With the option OFF, empty strings (and zeroes in Integer fields) sort to the TOP.
With the option ON, empty strings (and zeroes) sort to the BOTTOM.

That's all there is to it.

If you want "both" (to sort empty strings to the bottom, and not zeroes) then you can have this, but you have to make a separate field for sorting, as I showed above.  The reason that one sorts differently is because it is an expression.  Expressions always output a string-type value, and zero and empty are not equivalent for string-type values, as they are for Number type fields.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

andrewberg

  • Galactic Citizen
  • ****
  • Posts: 418
Re: Sort by "Number Plays"
« Reply #10 on: February 22, 2015, 08:43:43 pm »

Thanks for explaining it again so perfectly! Remember however that my initial aim was to have "Number plays" values sort LAST. Arguably the opposite of what you'd usually prefer, and only needed to move watched files to bottom for ease of overview...

Still I think the option should be rephrased in the dialogue; for it's not strings that get sorted but files to which the strings are assigned...
Logged
"To be is to do" (Socrates) - "To do is to be" (Sartre) - "Do be do be do" (Sinatra)
Pages: [1]   Go Up