Question: I'm using the following code to Draw an NSString on an NSImage.How can I make this text transparent 

```
text.draw(at:  NSZeroPoint, withAttributes: [NSFontAttributeName: font, NSForegroundColorAttributeName: NSColor.white])

```

How can I make this text transparent?

Please advice

Answer: 
```
$ sort -t_ -k5,5 -k8,8n file
abc_bla_bla_bla_reg0_bla_reg_1_0
abc_bla_bla_bla_reg0_bla_reg_2_0
abc_bla_bla_bla_reg0_bla_reg_5_0
abc_bla_bla_bla_reg0_bla_reg_10_0
abc_bla_bla_bla_reg0_bla_reg_15_0
abc_bla_bla_bla_reg2_bla_reg_7_0
abc_bla_bla_bla_reg2_bla_reg_9_0
abc_bla_bla_bla_reg2_bla_reg_15_0
abc_bla_bla_bla_reg3_bla_reg_3_0
abc_bla_bla_bla_reg3_bla_reg_5_0
abc_bla_bla_bla_reg3_bla_reg_26_0

```

That may or may not produce the output you expect if the `regN` value in the 5th column can include 2-digit numbers.
Using **awk**

```
$awk -F"_" 'function print_array(arr,max){ for(i=1; i<=max; i++) if(a[i]){print a[i], a[i]="";} } key==$5{a[$8]=$0; key=$5; max=$8>max?$8:max} key!=$5{print_array(a,max); key=$5; a[$8]=$0; max=$8} END{print_array(a,max)}' file

```

**Output**:

```
abc_bla_bla_bla_reg0_bla_reg_1_0  
abc_bla_bla_bla_reg0_bla_reg_2_0  
abc_bla_bla_bla_reg0_bla_reg_5_0  
abc_bla_bla_bla_reg0_bla_reg_10_0  
abc_bla_bla_bla_reg0_bla_reg_15_0 
abc_bla_bla_bla_reg2_bla_reg_7_0  
abc_bla_bla_bla_reg2_bla_reg_9_0  
abc_bla_bla_bla_reg2_bla_reg_15_0  
abc_bla_bla_bla_reg3_bla_reg_3_0 
abc_bla_bla_bla_reg3_bla_reg_5_0 
abc_bla_bla_bla_reg3_bla_reg_26_0

```

**Explanation:**

```
awk -F"_" '
    function print_array(arr,max)    #Simply prints the hashed array from i=1 to max value array is holding
    { 
        for(i=1; i<=max; i++) 
        if(a[i])
            {print a[i], a[i]="";} 
    } 

    key==$5{a[$8]=$0; max=$8>max?$8:max} #Key here denotes the 5th field for eg. reg0 in line one. Initially key is null and it will satisfy the condition mentioned below i.e key!=$5. If the 5th field matches with the key set in previous line then push the record into array where the index in array will be the value at field 8 based on which you want to sort your results. 

    key!=$5{print_array(a,max); key=$5; a[$8]=$0; max=$8} #If key doesn't matches the 5th line it signifies we have a new record set and before proceeding further print the array we stored for previous record set based on 5th field.

    END{print_array(a,max) #To print the last record set

    }' file

```

`key==$5{a[$8]=$0; max=$8>max?$8:max}` : `Key` here denotes the 5th field for eg. `reg0` in line one. Initially `key` is null and it will satisfy the condition mentioned below i.e `key!=$5`. If the 5th field `$5` matches with the key set in previous line then push the record into array where the index in array will be the value at field 8 based on which you want to sort your results. This will work irrespective of the number of digits in `$8`.

`key!=$5{print_array(a,max); key=$5; a[$8]=$0; max=$8}` If `key` doesn't matches the 5th line it signifies we have a new record set and before proceeding further print the array we stored for previous record set based on 5th field.

`END{print_array(a,max)` Just to print the last record set