diff --git a/NEWS.md b/NEWS.md index 06a6ffb..2b19b3f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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). diff --git a/R/pkrt-list.R b/R/pkrt-list.R index a6362d2..e0cc3fc 100644 --- a/R/pkrt-list.R +++ b/R/pkrt-list.R @@ -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 diff --git a/tests/testthat/test-pkrt-list.R b/tests/testthat/test-pkrt-list.R index 856e021..e8aced7 100644 --- a/tests/testthat/test-pkrt-list.R +++ b/tests/testthat/test-pkrt-list.R @@ -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") ) ) })