# Name-Value-Pairs nvp <- list( "Service"="AWSECommerceService", "Version"="2011-08-01", "AssociateTag"="PutYourAssociateTagHere", "Operation"="ItemSearch", "SearchIndex"="Books", "Keywords"="harry potter", "Timestamp"="2015-09-26T14:10:56.000Z", "AWSAccessKeyId"="123" )
Receive byte:
bytes <- function(chr){ as.data.frame(t(as.numeric(charToRaw(chr)))) }
Calculate bytes and change values
b <- lapply(names(nvp), bytes) b <- data.table::rbindlist(b, fill=TRUE) # other than base::rbind, this fills by NA
Order the names in the first column, then in the second, third, ... etc.
names(nvp)[do.call(order, as.list(b))] [1] "AWSAccessKeyId" "AssociateTag" "Keywords" "Operation" "SearchIndex" [6] "Service" "Timestamp" "Version"
So finally nvp[do.call(order, as.list(b))] returns in a properly sorted list
Rentrop
source share