Golang sorting solution
Code\ngo\nfunc sumDistance(nums []int, s string, d int) int {\n\tfinalPositions := make([]int, 0, len(nums))\n\tfor i, v := range nums {\n\t\tswitch s[i] {\n\t\
# Code\n```go\nfunc sumDistance(nums []int, s string, d int) int {\n\tfinalPositions := make([]int, 0, len(nums))\n\tfor i, v := range nums {\n\t\tswitch s[i] {\n\t\tcase \'L\':\n\t\t\tv -= d\n\t\tcase \'R\':\n\t\t\tv += d\n\t\t}\n\t\tfinalPositions = append(finalPositions, v)\n\t}\n\tsort.Ints(finalPositions)\n\tresult := 0\n\tbase := finalPositions[0]\n\tfor i := 1; i < len(finalPositions); i++ {\n\t\tresult = (result + (finalPositions[i] * i) - base) % 1000000007\n\t\tbase += finalPositions[i]\n\t}\n\treturn result % 1000000007\n}\n```
['Sorting', 'Go']