www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
aref
aset
concat
concatenate
dvector
get_keyword
get_keyword_ucase
gvector_digit_sort
gvector_sort
isarray
make_array
position
rowvector_digit_sort
serialize
split_and_decode
tree_md5
vector
vector_concat
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
Miscellaneous
Number
Phrases
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web & Internet
XML
XPATH & XQUERY

Functions Index

gvector_sort

Performs quicksort of a given array.
gvector_sort (inout data vector, in elements_in_group integer, in key_idx_in_group integer, in sort_ascending integer);
Description

The function gets an vector that consists of groups of elements. All groups are of equal size, namely elements_in_group, so the total length of data vector should be whole multiple of elements_in_group. One element of each group is a key of sorting; it is identified by its zero-based position within the group, key_idx_in_group. The sorting procedure edits data and reorders groups in such a way that their keys become ordered ascending or descending, depending on sort_ascending flag.

The simplest case is plain sorting of a uniform array. In this case every element is an individual group, elements_in_group is 1 and key_idx_in_group is 0.

Other popular case is sorting of result of dict_to_vector(). In this case, every item of the original dictionary is represended in the vector by a pair of elements (elements_in_group is 2), so to sort items by their keys, the key_idx_in_group is 0 and to sort them by associated values, the key_idx_in_group is 1.

Similarly, elements_in_block is 2 for arrays like "lines" or "params" of a VSP page.

Parameters
data – A group vector (gvector) to sort.
elements_in_group – The number of vector elements in every group, usually 1, should be in range 1 to 1024.
key_idx_in_group – Zero-based position of key element in group, should be nonnegative and less than elements_in_group.
sort_ascending – Direction of sorting, nonzero for ascending sort, zero for descending.
Return Types

The function returns number of groups in the data vector

.
See Also

gvector_digit_sort

rowvector_digit_sort