1

I would like to sort my @online resources after the date of access as given in the urldate field.

At the moment I can sort all entries sort by nty, but I would like to see the @online entries sorted by date of access.

\documentclass{article}
\usepackage[backend=biber,defernumbers=true]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\nocite{westfahl:space,aristotle:physics,ctan,baez/online,markey,sigfridsson}


\printbibliography[title=Unsorted]

\newrefcontext[sorting=nty]
\printbibliography[title=Alphabetic]

\newrefcontext[sorting=ynt]
\printbibliography[title=By year]
\end{document}

And the question is how to sort it after the date of extraction then.

moewe
  • 175,683
  • 1
    Please show us a minimal example document that reproduces the undesirable result you are seeing. It is really hard to tell from the description what exactly your problem is. – moewe Dec 20 '18 at 22:46
  • 1
    Please -- as usual here -- show us a short compilable code resulting in your problem. Do not forget to add two bib entries to your question ... – Mensch Dec 20 '18 at 22:47
  • 1
    Unfortunately the code shown is by far not enough to reproduce your issue. The code you show should be compilable without further modifications when pasted into an empty .tex file. Please have a look at https://tex.meta.stackexchange.com/q/228/35864 and https://tex.meta.stackexchange.com/q/4407/35864 to find out how to provide useful MWEs. – moewe Dec 20 '18 at 22:54
  • Hope it is right now – Metalhead Dec 20 '18 at 23:11
  • Thank you for including compilable code. It is a bit late for me and I might just be being thick, but I don't quite understand what exactly you are asking, i.e. what output you would like to see from the code example instead. Note that the implicit global sorting scheme is nty hence, the \printbibliography[title=Unsorted] sorts exactly the same as the following \printbibliography[title=Alphabetic]. – moewe Dec 20 '18 at 23:12
  • The problem is, that my teacher wants that the online sources are sorted by the date of the extraction/ the date of the last visit, and I haven't found a way to do that yet. – Metalhead Dec 20 '18 at 23:18
  • I have never seen that before, but if that is what you teachers want... All other sources are still to be sorted nty? – moewe Dec 20 '18 at 23:22
  • I have edited your question in an attempt to make it clearer. I hope I have not changed the intended meaning of anything. If so, please feel free to roll back and accept my apologies. – moewe Dec 20 '18 at 23:53

1 Answers1

1

If you want to sort @online sources by their urldate you will have to define a new sorting template. Cf. biblatex sorting by date, but note that our scheme needs to be based on url... date parts.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber,defernumbers=true]{biblatex}

\DeclareSortingTemplate{urldatenty}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field{urlyear}
    \literal{9999}
  }
  \sort{
    \field{urlmonth}
    \literal{99}
  }
  \sort{
    \field{urldate}
    \literal{99}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sortyear}
    \field{year}
  }
  \sort{
    \field{volume}
    \literal{0}
  }
}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  date    = {1980},
  url     = {http://example.com/~sir_humphrey/importance},
  urldate = {2018-10-01}
}
@online{elk,
  author  = {Anne Elk},
  title   = {A Theory on Bronotsauruses},
  date    = {1972},
  url     = {http://example.com/~elk/bronto},
  urldate = {2018-04-06}
}
@online{woolley,
  author  = {Bernard Woolley},
  title   = {On the Ablative Case in Ancient Greek},
  date    = {1981},
  url     = {http://example.com/~wooll/abl},
  urldate = {2018-01-02}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}


\begin{document}
\nocite{sigfridsson,worman,nussbaum,appleby,elk,woolley}

\printbibliography[nottype=online, title={\refname{} (sans \texttt{@online})}]
\newrefcontext[sorting=urldatenty]
\printbibliography[type=online, title={Online sources (sorted by \texttt{urldate})}]
\end{document}

Non-<code>@online</code> bib is sorted <code>nty</code> (the global scheme), the <code>@online</code>-bib is sorted by <code>urldate</code>.

In this case the same sorting could be achieved by making urldatenty the global sorting scheme (which means you could get rid of the \newrefcontext), but that would feel like cheating.

moewe
  • 175,683
  • @MrXeth If this answer solved your problem, you may want to consider upvoting (by clicking on the arrows next to the score; you need 15 reputation points before you can upvote) and marking it as the accepted answer (by clicking on the checkmark ✓). Accepting shows which solution worked for you. (Of course the same hold for your earlier questions.) – moewe Dec 20 '18 at 23:44
  • Done! Sorry for these many questions, but I'm writing a skilled work at informatics and my teacher told me to use latex, because it supports integrating code examples much more better than ms word. – Metalhead Dec 20 '18 at 23:52
  • @MrXeth Oh, don't be sorry about the number of questions you ask! If your questions are interesting and you give us enough information to answer them, i.e. if your questions are 'good', they are very welcome here: After all what would this site be without question? They keep this site going. Just please consider including a usable example document (MWE/MWEB) in your questions in future, so we don't have to ask for one before we can get started. – moewe Dec 20 '18 at 23:56