Why not one use python buildin sort function for list? Is it not the point of question?

thank you for your help
I try another code:
class Solution(object):
def sortColors(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums inplace instead.
"""
dic={}
for i in nums:
dic[i]=dic.get(i,0)+1
for j in range(0,dic[0]):
nums[j]=0
for k in range(dic[0],dic[0]+dic[1]):
nums[k]=1
for p in range(dic[0]+dic[1],dic[0]+dic[1]+dic[2]):
nums[p]=2
It works well on my own computer, but in leetcode, it does not work because of keyerror[1]Can you tell me where is the problem ?
thank you

class Solution(object):
def sortColors(self, nums): """ :type nums: List[int] :rtype: void Do not return anything, modify nums inplace instead. """ dic={} for i in nums: dic[i]=dic.get(i,0)+1 for j in range(0,dic[0]): nums[j]=0 for k in range(dic[0],dic[0]+dic[1]): nums[k]=1 for p in range(dic[0]+dic[1],dic[0]+dic[1]+dic[2]): nums[p]=2
it works in my computer, but will not work in leetcode. what is the problem with my codes?
thx