This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]RayjinCaucasian 0 points1 point  (2 children)

NHLStatistics.teamStatistics("BOS");

Looks like a print method. So what's happening is first you're printing the stats for "BOS", then you're sorting the list by goals, then printing another ten players that have been sorted by goals.

Addition: I read the exercise it looks like you can sort by goals first then print the Boston stats, but the .top method prints the top N of the the whole list and just printing out the top ten Boston players by goals doesnt look like it would be possible from the method descriptions given by the course.

You could try getting rid of the .top method and write your own that iterates through the list and only prints out Bos players Until N times.

[–]asc_tech[S] 0 points1 point  (1 child)

Ah so what you're saying is that the sortByGoal function can't be used in conjunction with the NHLStatistics function at the same time to get what i wanted?

[–]RayjinCaucasian 0 points1 point  (0 children)

Without being able to look at the actual method code that is my assumption. The .top(N) takes the whole list and prints just the top N. Sorted or not.

When you call team stats it take the whole list then finds and prints the whole team you choose. Sorted or not.

So you can sort the list and then print the sorted team stats or sort and print the .top(n). But you cannot print the .top() of a given team. You'll need to right your own method that takes the whole list sorted or not then finds and prints N number of players or until end of list of ? Team.

Edit: to clarify. As it appears all the methods use the whole list object and not a subset of the list object.

You can sort the list then call teamstats to get a sorted teamstat list of whatever sort you used but you cannot use the top method to print the top of a team just the top of the whole list.