Skip to content

Commit

Permalink
Fix alphabetical ordering (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgallou authored Oct 9, 2024
1 parent 341f763 commit f044755
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# pakret (development version)

* Fixed alphabetical ordering of package names in `as.data.frame.pkrt_list()` (#19).

# pakret 0.2.0

* Added `book` as a second BibTeX type that should be used in priority when getting the reference of a package (previously, the priority was given to `manual` entries only). This allows for a slightly better handling of multi-reference packages by using a more general reference when there's a `book` but no `manual` BibTeX entry available (#15).
Expand Down
2 changes: 1 addition & 1 deletion R/pkrt-list.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ as.data.frame.pkrt_list <- function(x, ...) {

sort.pkrt_list <- function(x, ...) {
pkgs <- vapply(x, function(.x) attr(.x, "pkg"), character(1L))
x[factor(pkgs)]
x[sort(pkgs)]
}

#' @export
Expand Down
9 changes: 5 additions & 4 deletions tests/testthat/test-pkrt-list.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ test_that("pkrt_list() makes a list of citations", {
test_that("citation lists can be turned into data frames", {
load_foo()
load_bar()
citations <- pkrt_list("foo", "bar")
local_pkg("zzz", Version = "0.1.0")
citations <- pkrt_list("zzz", "bar", "foo")

expect_equal(
as.data.frame(citations),
data.frame(
Package = c("bar", "foo"),
Version = c("0.2.0", "1.0.0"),
Reference = c("@bar", "@foo")
Package = c("bar", "foo", "zzz"),
Version = c("0.2.0", "1.0.0", "0.1.0"),
Reference = c("@bar", "@foo", "@zzz")
)
)
})
Expand Down

0 comments on commit f044755

Please sign in to comment.