```
def search(self, nums, target):
length=len(nums)
bgnI=0; endI=length-1
while endI>=bgnI:
mid=(bgnI+endI)/2
if nums[mid]==target:
return mid
if nums[endI]<nums[bgnI]:
if nums[mid]>nums[bgnI]:
if target<=nums[mid-1] and target>=nums[bgnI]:
endI=mid-1
else:
bgnI=mid+1
else:
if target<=nums[endI] and target>=nums[mid+1]:
bgnI=mid+1
else:
endI=mid-1
else:
if nums[mid]>target:
endI=mid-1
else:
bgnI=mid+1
return -1
```