+5
Under review

Advanced Sorting?

Martin Roth 10 years ago updated by Christian Fritz 5 years ago 2
I'm using BibBase with Zotero for my publication list. Currently, I'm, using the group option to sort my publications according to categories (monographs, translations, articles...) This works fine, but in order to determine the order of the categories on the website, I have to add a number in front of them. Also, doing so requires another group specification for year if I want the entries to be sorted in the order of appearance, which messes the site up a bit. Is there any way of sorting/grouping entries "silently", without visualizing them on the website, or a future plan to enable a feature that allows something like that?
Ideally, this would allow me to have 

1. monographs
...
...


2. articles
...
...

listed without the number to sort them, and the entries automatically sorted by year or another category without the "group" option.

Just a suggestion! I love your work.
Martin
+3

I also have had this problem recently, and solved it (to some extent) via Javascript for intra-group sorting. The bibbase groups (first-level groups) have html class ".bibbase_group_body." If we query them using jQuery, we'll be able to get a list of paper entries in each group, and sort them using a custom Javascript function.


In an example, this script sorts entries within a group by year, then by position of my last name:

    <script>
        var lastname = "nguyen";
        $('.bibbase_group_body').each(function() {
            // Get the current element via jQuery
            var context = $(this); 
            // Extract and remove list of all children div
            var listitems = context.children('div').get();
            // Sort items by year
            listitems.sort(function(a, b) {
                var a_year = parseInt(a.id.substr(a.id.length - 4));
                var a_pos = parseInt(a.id.indexOf(lastname));
                var b_year = parseInt(b.id.substr(b.id.length - 4));
                var b_pos = parseInt(b.id.indexOf(lastname));
                // Compare the 2 keys, reverse the result to descend
                if (a_year < b_year) return 1;
                if (a_year > b_year) return -1;
                // Equal year, compare position of lastname index
                if (a_pos < b_pos) return -1;
                if (a_pos > b_pos) return 1;
                // All else equal, compare id strings
                return b.id.toUpperCase().localeCompare(a.id.toUpperCase());
            });
            // Add back list of sorted children
            $.each(listitems, function(index, item) {
               context.append(item); 
            });
        });
    </script>

This script should be added after Bibbase and jQuery are loaded (probably at the end of <body> tag). Results can be seen here: http://www.dnguyen.io/publications/. Note that this script only runs once at the first time the page loads, so if you use "Group by" after the page loads, sorted order will be lost, and you will need to refresh the page to get it back.


Hope this helps!

Under review

While we haven't quite implemented the feature you are asking about (sorting groups), we did just add a new option to control the sorting of publications within each group. Please see the "sort" option on the updated help page.