[關鍵字]: R, string, sort
[重點摘要]:
今天踩到地雷了。
我寫了一個script,在Rstudio和console下的行為卻不同,經過一兩天的debug才發現:
```r
a <- c(letters, LETTERS) # 英文的大小寫字母
sort(a)
```
的結果會和系統環境有關!!
在sort的說明文件中有:
```
The sort order for character vectors will depend on the collating sequence of the locale in use: see Comparison. The sort order for factors is the order of their levels (which is particularly appropriate for ordered factors).
```
例如:http://rpubs.com/wush978/sorting
FYI