An apparatus for quantizing an input vector representing part of an audio or speech signal comprising: - means for identifying one or more target vectors from a plurality of candidate vectors, wherein each candidate vector having positive elements in a decreasing order such that a first element is larger than a second element and being associated with a respective class of one or more code vectors of a codebook and at least one of said candidate vectors being associated with a respective class of two or more code vectors that comprise said respective candidate vector and at least one code vector obtainable from said respective candidate vector by one of permutation and signed permutation, wherein said one or more target vectors are one or more candidate vectors, among all candidate vectors of said plurality of candidate vectors, with the smallest distance or distances towards a sorted representation of the input vector;, means for determining the sorted representation of the input vector by sorting elements of an absolute valued input vector in a decreasing order such that a first element is larger than a second element; means for initially selecting a candidate vector from said plurality of candidate vectors as said reference vector; means for checking, for each further candidate vector of said plurality of candidate vectors, that a distance between said sorted representation of said input vector and said further candidate vector is larger than a distance between said sorted representation of said input vector and the reference vector, wherein said means for checking are characterized by: checking if an absolute value of a difference between said distance between said further candidate vector and said reference vector and said distance between said reference vector and said sorted representation of said input vector is larger than said distance between said reference vector and said sorted representation of said input vector, and wherein said distance between said further candidate vector and said reference vector is retrieved from a memory as a pre-computed value, wherein the memory comprises pre computed distances with respect to all possible pairings of candidate vectors; when said checking yields a negative result a nearest neighbour search is performed in order to determine whether the further candidate vector is nearer to the input vector than the reference vector, the nearest neighbour search is based on: computing a distance between said sorted representation of said input vector and said further candidate vector; checking if said computed distance between said sorted representation of said input vector and said further candidate vector is smaller than said distance between said reference vector and said sorted representation of said input vector, wherein said reference vector is set to said further candidate vector when the distance is smaller between said sorted representation of said input vector and said further candidate vector than between said reference vector and said sorted representation of said input vector; when said checking yields a non-negative result the nearest neighbour search is not performed; and at the end of the checking the reference vector is set to the target vector. - means for identifying one or more target vectors from a plurality of candidate vectors, wherein each candidate vector having positive elements in a decreasing order such that a first element is larger than a second element and being associated with a respective class of one or more code vectors of a codebook and at least one of said candidate vectors being associated with a respective class of two or more code vectors that comprise said respective candidate vector and at least one code vector obtainable from said respective candidate vector by one of permutation and signed permutation, wherein said one or more target vectors are one or more candidate vectors, among all candidate vectors of said plurality of candidate vectors, with the smallest distance or distances towards a sorted representation of the input vector;, computing a distance between said sorted representation of said input vector and said further candidate vector; checking if said computed distance between said sorted representation of said input vector and said further candidate vector is smaller than said distance between said reference vector and said sorted representation of said input vector, wherein said reference vector is set to said further candidate vector when the distance is smaller between said sorted representation of said input vector and said further candidate vector than between said reference vector and said sorted representation of said input vector; when said checking yields a non-negative result the nearest neighbour search is not performed; and at the end of the checking the reference vector is set to the target vector.