package main
import (
"fmt"
"sort"
"strings"
"unicode"
)
func customSort(input string) string {
chars := strings.Split(input, "")
sort.Slice(chars, func(i, j int) bool {
a, b := chars[i], chars[j]
if unicode.IsDigit([]rune(a)[0]) && unicode.IsLetter([]rune(b)[0]) {
return true // Digits before letters
}
if unicode.IsLetter([]rune(a)[0]) && unicode.IsDigit([]rune(b)[0]) {
return false // Letters after digits
}
return a < b
})
return strings.Join(chars, "")
}
func main() {
input := "d25ea4b3c1"
sortedInput := customSort(input)
fmt.Println("Custom sorted string:", sortedInput)
}
/*
run:
Custom sorted string: 12345abcde
*/