Skip to content

Commit a082fd9

Browse files
committed
construct env only once to get sort key funs
1 parent 9ccfb52 commit a082fd9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

R/09sort.R

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@
5454
#' BibOptions(restore.defaults = TRUE)
5555
sort.BibEntry <- function(x, decreasing = FALSE, sorting = BibOptions()$sorting,
5656
.bibstyle = BibOptions()$bib.style, ...){
57+
sort.fun.env <- GetFormatFunctions(DateFormatter = I)
5758
if (is.null(sorting))
5859
sorting <- "nty"
5960
if (sorting == 'debug' || .bibstyle == 'draft')
6061
return(x[order(names(x))])
6162
if (sorting != "none" || .bibstyle == "alphabetic"){
62-
aut <- MakeBibLaTeX()$sortKeys(x)
63-
yr <- MakeBibLaTeX()$sortKeysY(x)
64-
ps <- MakeBibLaTeX()$sortKeysPS(x)
65-
ttl <- MakeBibLaTeX()$sortKeysT(x)
63+
aut <- sort.fun.env$sortKeys(x)
64+
yr <- sort.fun.env$sortKeysY(x)
65+
ps <- sort.fun.env$sortKeysPS(x)
66+
ttl <- sort.fun.env$sortKeysT(x)
6667
if (sorting %in% c('nyvt', 'anyvt'))
67-
vol <- MakeBibLaTeX()$sortKeysV(x)
68+
vol <- sort.fun.env$sortKeysV(x)
6869
}
6970
if (.bibstyle == 'alphabetic' || sorting == 'anyt' || sorting == 'anyvt')
70-
alabs <- MakeBibLaTeX()$sortKeysLA(x, yr)
71+
alabs <- sort.fun.env$sortKeysLA(x, yr)
7172

7273
if (sorting != "none"){
7374
ord <- switch(sorting, nyt = order(ps, aut, yr, ttl, decreasing = decreasing),
@@ -95,14 +96,14 @@ sort.BibEntry <- function(x, decreasing = FALSE, sorting = BibOptions()$sorting,
9596
if (hasArg(return.labs) && !length(unlist(x$.index))){
9697
if (.bibstyle %in% c("authoryear", "authortitle")){
9798
if (sorting == "none")
98-
aut <- MakeBibLaTeX()$sortKeys(x)
99+
aut <- sort.fun.env$sortKeys(x)
99100
suppressWarnings({
100101
ind <- nchar(aut) == 0L & !x$bibtype %in% c("XData", "Set")
101102
aut[ind] <- x$title[ind]
102103
x$.duplicated <- duplicated(aut)
103104
})
104105
if (.bibstyle == "authoryear"){
105-
tmp <- MakeAuthorYear()$GetLastNames(x)
106+
tmp <- sort.fun.env$GetLastNames(x)
106107

107108
# sortyear could mess things up, so can't reuse yr
108109
yr <- sapply(unclass(x), function(dat)

0 commit comments

Comments
 (0)