Question: I am currently trying to use the built in function Sorted to sort a list with a class attribute called scores.

Here the sorted function works with just a list, it correctly orders the scores in ascending order.

```
Scores = [1,5,19,0,900,81,9000]

print(sorted(Scores))

```

However when I try to apply this function to my list which has a class attribute, An error is returned:
AttributeError: 'list' object has no attribute 'Score'

Here is my code:

```
print(sorted(RecentScores.Score))

```

Any help would be much appreciated.

Below is my class being initialised and the list RecentScores

```
class TRecentScore():
  def __init__(self):
    self.Name = ''
    self.Score = 0

RecentScores = [1,5,0]

```

Answer: 
In the class definition, you must first take as inputs the name and score in `__init__` as shown below:

```
class TRecentScore():
    def __init__(self, Name, Score):
        self.Name = Name
        self.Score = Score

```

Then only it makes sense to assign name and score inside the class.
Next, the `RecentScores` instance of the class `TRecentScore` has to be instantiated passing the name and score as arguments to the initialisation. This can be done as shown below:

```
RecentScores = TRecentScore('Recent Scores',[1,5,0])
print(sorted(RecentScores.Score))

```

This will print out the sorted score. Hope this helps!
If you always want your scores list sorted, you can sort the list in place, using sorted creates a new list:

```
class TRecentScore():
    def __init__(self, name, score):
        self.Name = name
        self.score = score
        self.score.sort()

RecentScores = TRecentScore("score list", [1,5,19,0,900,81,9000])
print (RecentScores.score)
[0, 1, 5, 19, 81, 900, 9000]

```