#!/usr/bin/Rscript keys <- c(5, 28, 19, 15, 20, 33, 12, 17, 10) hash <- function(key) as.character(key%%9) table <- list() for(key in keys) table[[hash(key)]] <- c(table[[hash(key)]], key) for(key in sort(names(table))) cat(key, ":", table[[key]], "\n")