Question: I am using AQGridView in my project. we need to create a black colored border around each image. Can anyone help me on this. 

Thanks in advance.

Regards,
Jas.

Answer: 
You can create two user defined functions and use them as per your need. This will offer more generic solution. 

```
[jaypal:~/Temp] cat file
a  212
b  323
c  23
d  45
e  54
f  102
[jaypal:~/Temp] awk '
function max(x){i=0;for(val in x){if(i<=x[val]){i=x[val];}}return i;}
function min(x){i=max(x);for(val in x){if(i>x[val]){i=x[val];}}return i;}
{a[$2]=$2;next}
END{minimum=min(a);maximum=max(a);print "Maximum = "maximum " and Minimum = "minimum}' file
Maximum = 323 and Minimum = 23

```

In the above solution, there are 2 user defined functions - `max` and `min`. We store the column 2 in an array. You can store each of your columns like this. In the `END` statement you can invoke the function and store the value in a variable and print it. 

Hope this helps!

**Update:**

Executed the following as per the latest example - 

```
[jaypal:~/Temp] awk '
function max(x){i=0;for(val in x){if(i<=x[val]){i=x[val];}}return i;}
function min(x){i=max(x);for(val in x){if(i>x[val]){i=x[val];}}return i;}
/^#/{next}
{a[$6]=$6;next}
END{minimum=min(a);maximum=max(a);print "Maximum = "maximum " and Minimum = "minimum}' sample
Maximum = 222 and Minimum = 3.01

```
If your file contains empty lines, neither of the posted solutions will work.
For correct handling of empty lines try this:

```
$ cat f.awk
BEGIN{getline;min=max=$6}
NF{
    max=(max>$6)?max:$6
    min=(min>$6)?$6:min
}
END{print min,max} 

```

Then run this command:

```
sed "/^#/d" my_file | awk -f f.awk

```

At first it catches the first line of the file to set min and max.
Than for each non-empty line it use the ternary operator check,
if a new min or max was found. At the end the result ist printed.

HTH Chris