Sort by date field in AIX

I wanted to sort the below data on 4th field(comma seperator) based on month and date and time on AIX OS.

Input data:

3,AJ,30 Jul 06:30,30 Jul 06:30
5,AJ,30 Jul 06:30,30 Jul 06:49
10,AJ,30 Jul 06:30,02 Jan 05:41
4,AJ,30 Jul 06:30,30 Jul 06:36
2,AJ,30 Jul 06:30,28 Jul 06:45
9,AJ,30 Jul 06:30,04 Aug 05:41
1,AJ,30 Jul 06:30,04 Aug 06:25
1,AJ,30 Jul 06:30,28 Jul 06:39
6,AJ,30 Jul 06:30,04 Jun 06:55
7,AJ,30 Jul 06:30,30 Jul 06:55
8,AJ,30 Jul 06:30,30 Jul 08:54
9,AJ,30 Jul 06:30,04 Jun 05:41

Expected Output:

10,AJ,30 Jul 06:30,02 Jan 05:41
9,AJ,30 Jul 06:30,04 Jun 05:41
6,AJ,30 Jul 06:30,04 Jun 06:55
1,AJ,30 Jul 06:30,28 Jul 06:39
2,AJ,30 Jul 06:30,28 Jul 06:45
3,AJ,30 Jul 06:30,30 Jul 06:30
4,AJ,30 Jul 06:30,30 Jul 06:36
5,AJ,30 Jul 06:30,30 Jul 06:49
7,AJ,30 Jul 06:30,30 Jul 06:55
8,AJ,30 Jul 06:30,30 Jul 08:54
9,AJ,30 Jul 06:30,04 Aug 05:41
1,AJ,30 Jul 06:30,04 Aug 06:25

---------- Post updated at 02:40 PM ---------- Previous update was at 01:25 PM ----------

In unix I am able to do above with below code but I am not able to do same in AIX as M option is not there so can anyone suggest how to do ?

sort -t, -k4.3M -k4 -k4.8,4.12 file_name

I'm afraid you need to convert the file to numeric months, then, sort it, and convert back. Try

awk '
BEGIN           {for (i=split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", T); i>0; i--) NM[T]=i
                }
                {$2=sprintf ("%02d", NM[$2])
                 $4=sprintf ("%02d", NM[$4])
                }
1
' file |
sort -t, -k4.3n -k4 -k4.8,4.12 |
awk '
BEGIN           {split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", NM)
                }
                {$2=sprintf ("%s", NM[$2+0])
                 $4=sprintf ("%s", NM[$4+0])
                }
1

Not sure this is the most elegant/efficient solution, though.

You could also try downlonding aixtools.gnu.coreutils - info available at coreutils - AIXTOOLS

You will also need aixtools.gettext or aixtools.gnu.gettext (via gettext - AIXTOOLS)

These are installp packages, and I have been assuming that people know how to work with installp. That assumption seems to be wrong, based on some feedback I have gotten the last two weeks.

Note: aixtools.gnu.coreutils is the latest version I have packaged. Unfortunately, it is not installing as smoothly as I would like. In that case install the 8.21 version (I have been using that for years).

The "gettext" fileset is also needed - as gnu uses gettext for language support.

FYI: gnu sort is part of coreutils.

Please keep me posted of any issues you have. It may take 24 hours before I have time to look into it, but I shall "correct" asap.