As this is a rather specific question and in lieu of a MWE some context:
I am working on a personalized version of the tufte-book class. In the process I am now at a point where I think I need a way to sort a list of biblatex-keys in order of the number they have. This is because I have extended the cite-command. (Note: tufte-book uses bibtex in the vanilla-version, I changed that to biblatex with biber backend, in case that is relevant)
In tufte-book when you call \cite{key1,key2,..} what really gets called is something like
% Normal \cite behavior
\newcounter{@tufte@num@bibkeys}%
\newcommand{\@tufte@normal@cite}[2][0pt]{%
\hiddencite{#2}
% Snag the last bibentry in the list for later comparison
\let\@temp@last@bibkey\@empty%
\@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}%
\marginnote[#1]{%
% Loop through all the bibentries, separating them with semicolons and spaces
\normalsize\normalfont\@tufte@citation@font%
\setcounter{@tufte@num@bibkeys}{0}%
\@for\@temp@bibkeyx:=#2\do{%
\ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
{\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\hiddencite{\@temp@bibkeyx}\bibentry{\@temp@bibkeyx}}%
{\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\hiddencite{\@temp@bibkeyx}\bibentry{\@temp@bibkeyx};\ }%
\stepcounter{@tufte@num@bibkeys}%
}%
}%
}
This already includes some changes from me (the goal is to have the full citation not as a footnote but as a marginnote with the citation number visible, see picture below). Hiddencite is nothing but the original cite which I stored because it gets changed from tufte-book. However, this does not work as good as the original cite command, because the list (#2) is not sorted.
here's an exemplary result to show my problem

generated by
some citations\cite{Tufte2001,Tufte1990,Tufte1997,Tufte2006}
same citations in different ordering \cite{Tufte2001,Tufte2006,Tufte1990,Tufte1997}
My goal is to find a way that both calls generate the same output (in the main text and the marginnote)
and now the actual question: How would I achieve a sorting of the list of citation keys I have? I want something that turns the argument key1,key3,key2,key4 into key1,key2,key3,key4. (Assuming that is the correct order).
What I did try is to look into the natbib and biblatex packages how they handle this, but I frankly failed to understand the code.
Final remark: I was asked how one would achieve such behaviour, this is not my idea (Personally I would be fine with a plain bibliography at the end)
biblatexdoes have an optionsortciteswhich sorts citations according to the applicable sorting scheme if activated. See order of multiple keys in \cite-command and In-text references are not alphabetically ordered. – moewe Aug 06 '15 at 17:26tufte-bookto work withbiblatex? In the current version it should not take a lot more than loading thedocumentclasswith thenobiboption and then loadingbiblatexlater. Of course, your citation style looks non-standard, but that should not be a Tufte issue.) – moewe Aug 06 '15 at 17:33biblatexwhich then allows sorting. The way you do it now I don't see how you could possibly do proper sorting: Onlybiblatexknows about the order and can do sorting, but your wrapper passes the bibkeys tobiblatexone by one at which point the sorting feature is somewhat pointless. – moewe Aug 06 '15 at 17:38\citechanges when called inside a sidenote), but I have spent some time on this, so any suggestions are appreciated. I am going to try to come up with a presentation that is less cluttered about with tufte-specifics,. With respect to the sorting: My idea was that i have access to\citenum, so I could do a string comparison on that – Bort Aug 06 '15 at 17:39biblatex. And with citations I think it is always way better to define abiblatex-y\DeclareCiteCommandthan to hack something together using\def/\newcommands on a document-level. – moewe Aug 06 '15 at 17:42