dcalvert
dcalvert

Reputation: 73

How to sort a list of structs based on the lastName variable of the struct

Before you ask, yes, I must use a list. I can not use a slice or anything else. So, I have a list full of structures, but the list needs to be sorted based on the lastname variable of the struct. I've tinkered with things but ultimately have nothing to show for it. I'm not asking for an answer, but just some guidance in the right direction. Any help would be appreciated!

Upvotes: 1

Views: 122

Answers (1)

ladygremlin
ladygremlin

Reputation: 464

So since you have to use a golang list, I'd recommend looking into

Solutions involving slices likely won't help you since you'll have to do linked list comparisons (and Go's implementation of lists is a little complicated!) Another hint: you'll likely have to do for loop iterations, so expect some O(n^2) complexity.

Hope this helps! :)

Upvotes: 4

Related Questions