I'm having trouble trying to pipe a sort with a gawk. I currently have:

```
gawk -f p3a01.awk unsortedNames.txt | sort | gawk -f p3a01.awk

```

this is however giving me the wrong results. The gawk seems to work fine if I do something like:

```
gawk -f p3a01.awk unsortedNames.txt | sort > test1.out
gawk -f p3a01.awk test1.out

```

I'm not sure if there is a proper way to directly pipe sort to gawk. I would ideally like to do this all on one line

Snip of `unsortedNames.txt`:

```
Faye King
Lenny R Graph
I M Board
Grey White

```

`p3a01.awk` (prints last name first then rest of the name):

```
BEGIN{}
{
      printf $NF " ";
      $NF="";
      print $0;
}
END{}

```

`p3a02.awk` (prints the file in the original order after it has been ordered by last name):

```
BEGIN{}
{
     for(i=2;i<=NF;i++){
         printf $i " ";
     }
     print $1;
}
END{}

```

Final result (sorted by last name):

```
I M Board
Lenny R Graph
Faye King
Grey White

```