Here is my code:

```
class Solution(object):
def nextGreaterElement(self, n):
"""
:type n: int
:rtype: int
"""
work,index=[ele for ele in str(n)],-1
for i in range(len(work)-1,0,-1):
if int(work[i-1])<int(work[i]):
index=i-1
break
else:
return -1
key=index
for i in range(len(work)-1,index,-1):
if int(work[i])>int(work[index]):
key=i
break
#print(work)
#print("%d %d" %(index,key))
return int(''.join(work[:index]+[work[key]]+sorted(work[index:key]+work[key+1:])))
```

But I got the information below:

Can anyone help?