func (a Routes) Less(i, j int) bool {
	arrayI := strings.Split(a[i].Source.URL, "/")
	arrayJ := strings.Split(a[j].Source.URL, "/")
	lenI := len(arrayI)
	lenJ := len(arrayJ)
	if arrayI[lenI-1] == "" {
		lenI--
	}
	if arrayJ[lenJ-1] == "" {
		lenJ--
	}
	return lenI > lenJ
}
Less compares two elements of the array
package config
import (
	"context"
	"fmt"
	"math/rand"
	"strings"
	"github.com/spaceuptech/helpers"
)
type GlobalRoutesConfig struct {
	RequestHeaders  Headers `json:"headers" yaml:"headers" mapstructure:"headers"`
	ResponseHeaders Headers `json:"resHeaders" yaml:"resHeaders" mapstructure:"resHeaders"`
}
type Routes []*Route
func (a Routes) Len() int { return len(a) }
func (a Routes) Swap(i, j int) { a[i], a[j] = a[j], a[i] }