Sort() is not able to sort by dimension


#1

According to the documentation of SciDB 13.6 (scidb.org/HTMLmanual/13.6/scidb_ug/re67.html), the sort function is able to sort on attributes and dimensions.
I get an error when trying to sort by dimension:

[code]sort(m4x4, j);

UserQueryException in file: src/query/parser/ALTranslator.cpp function: matchOperatorParam line: 1463
Error id: scidb::SCIDB_SE_QPROC::SCIDB_LE_WRONG_OPERATOR_ARGUMENT2
Error description: Query processor error. Parameter must be attribute name or constant with type ‘int64’ or end of arguments.
sort(m4x4, j)
^
Failed query id: 1100890644372[/code]

Am I missing something trivial?

– Emmanuel


#2

Ummm … .

sort(array,
   [, attribute [ asc  |  desc ]]...
   [, chunk_size ] );

At the moment, we can only sort on a list of attributes. We can specify whether you want to sort that in ascending or descending order. But you can’t sort by a dimension.

To better understand what’s going on, what is the result you’re trying to see in your output? We know, for example, that some folk about like to sort an array like this “along each dimension”. That is, return an array that has the same shape and the same number of cells as the input, only have the values in the array ordered along each dimension.

A < val > [ I, J ] 

  +---+---+---+---+
  | 3 | 2 | 1 | 0 |
  +---+---+---+---+
  | 0 | 1 | 2 | 3 |
  +---+---+---+---+
  | 3 | 0 | 2 | 1 |
  +---+---+---+---+

sort ( A, v, J ) ==>

  +---+---+---+---+
  | 0 | 1 | 2 | 3 |
  +---+---+---+---+
  | 0 | 1 | 2 | 3 |
  +---+---+---+---+
  | 0 | 1 | 2 | 3 |
  +---+---+---+---+

Is that what you’re trying to achieve? Or something else?


#3

You could also apply the dimension and sort by that…this is pretty efficient. For example:

store(build(val:double[i=0:3,4,0,j=0:3,4,0],i*4+j),m4x4);

sort( apply(m4x4, k, j), k)