psort | R Documentation |

Similar to `base::sort`

but just for character vector and partially using parallelism.
It is currently experimental and might change in the future. Use with caution.

psort(x, decreasing=FALSE, na.last=NA, nThread=getOption("kit.nThread"),c.locale=TRUE)

`x` |
A vector of type character. If other, it will default to |

`na.last` |
For controlling the treatment of |

`decreasing` |
A boolean indicating where to sort the data in decreasing way. Default is |

`nThread` |
Number of thread to use. Default value is |

`c.locale` |
A boolean, whether to use C Locale or R session locale. Default TRUE. |

Returns the input `x`

in sorted order similar to `base::sort`

but usually faster. If `c.locale=FALSE`

, `psort`

will return the same output as `base::sort`

with `method="quick"`

, i.e. using R session locale. If `c.locale=TRUE`

, `psort`

will return the same output as `base::sort`

with `method="radix"`

, i.e. using C locale. See example below.

Morgan Jacob

x = c("b","A","B","a","\xe4") Encoding(x) = "latin1" identical(psort(x, c.locale=FALSE), sort(x)) identical(psort(x, c.locale=TRUE), sort(x, method="radix")) # Benchmarks # ---------- # strings = as.character(as.hexmode(1:1000)) # x = sample(strings, 1e8, replace=TRUE) # system.time({kit::psort(x, na.last = TRUE, nThread = 1L)}) # user system elapsed # 2.833 0.434 3.277 # system.time({sort(x,method="radix",na.last = TRUE)}) # user system elapsed # 5.597 0.559 6.176 # system.time({x[order(x,method="radix",na.last = TRUE)]}) # user system elapsed # 5.561 0.563 6.143

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.