Sort by Multiple Keys

Funnel allows for any number of sort keys for one sort. Multiple keys are strung together as a single key for the sorting process. Each key can be a different type, and a different direction. This example will sort on two keys.

The general format of a key specification is --keys (one key definition)(a second key)(a third key) and so on.

A key definition is (keyType, --offset offset, --length length, direction, --format format).

direction and format are optional. The offset is zero-relative.

Direction values:

  • ASC – ascending
  • DESC- descending
  • AASC- absolute ascending
  • ADESC- absolute descending

Absolute direction means upper and lowercase are considered the same, and positive and negative numbers are the same for sorting purposes.

Key Types:

  • String – normal readable character data like “ABC”
  • Integer – a readable integer value like “1234″
  • Float – a readable floating point number like “456.78″
  • BInteger – an encoded integer value
  • BFloat – an encoded floating point number
  • Date – a readable Java-like date

The encoded keys are the standard Java encoded numbers for Byte, Short, Integer, Long, Float, and Double. The length of the key determines which one it is.

  • BInteger length 1 = Byte
  • BInteger length 2 = Short
  • BInteger length 4 = Integer
  • BInteger length 8 = Long
  • BFloat length 4 = Float
  • BFloat length 8 = Double