attempt 4: adding eq sorting code to this file