Ignoring a specific field wile sorting

I’ve data as shown, I was able to read it as CSV and do sorting by time, as below:

type Interface interface {
	Len() int
	Less(i, j int) bool
	Swap(i, j int)
}

func (t Transactions) Len() int { return len(t) }
func (t Transactions) Less(i, j int) bool {
	t1, _ := time.Parse("1/2/2006 03:04:05 PM", t[i].TrxTime)
	t2, _ := time.Parse("1/2/2006 03:04:05 PM", t[j].TrxTime)
	return t1.Before(t2)
}                                  
func (t Transactions) Swap(i, j int) { t[i], t[j] = t[j], t[i] }

It is sorting by the time correctly, but found it is sorting by Warehouse as well, the output is:

I00003 20110  320 TRF-003009
I00003 20111  320 TRF-003009
I00003 20111 -320 TRF-003009
I00003 20119 -320 TRF-003009
I00003 20119 320 Opening

enter image description here

How can I force sorting the data by time ONLY ignoring other parameters, or by time and Qty and force the ignorance of the warehouse code consideration?

You haven’t provided us with code and data for a reproducible error. Therefore, we can’t be sure what is happening.

It looks like you are not sorting at all. As always, check for errors.

03:04:05 PM is not the same as 15:04:05.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.