JSON/q

A JSON-based data access specification

Arguments

[
  [
    5, 
    4, 
    1, 
    3, 
    9, 
    8, 
    6, 
    7, 
    2, 
    0
  ]
]

Query

{
  "group": {
    "into": "g", 
    "by": "n%5"
  }, 
  "as": "n", 
  "from": "args[0]", 
  "select": {
    "remainder": "g.key", 
    "numbers": "g"
  }
}

Results

[
  {
    "remainder": 0, 
    "numbers": [
      5, 
      0
    ]
  }, 
  {
    "remainder": 1, 
    "numbers": [
      1, 
      6
    ]
  }, 
  {
    "remainder": 2, 
    "numbers": [
      7, 
      2
    ]
  }, 
  {
    "remainder": 3, 
    "numbers": [
      3, 
      8
    ]
  }, 
  {
    "remainder": 4, 
    "numbers": [
      4, 
      9
    ]
  }
]