O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sort array indexes using asorti()

The asorti() function takes all the array indexes, sorts them and stores them in a new array, as array values for the new array with an index starting from 1 to n. Numeric values come before string values in the sorting order. The following is the syntax for sorting the array index using the asorti() function:

n = asorti (arr)

Let's understand the working of the asorti() function using examples. In the following example, we will use the asorti() function to sort the array indexes as per their values. The only side effect of using the asorti() function with default parameters is that the array's original index will be lost and the new array is assigned indexes from 1 to n, and now the new array elements will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required