-1

I am trying to make a program that accepts user input and sorts the characters of a string input in ascending order.

0

1 Answer 1

-1

The sorting algorithm used can vary, but a common approach is to use a bubble sort algorithm.

.data
string db 'sortstring',0
sorted db 20 dup(0)

.code
main proc
    mov edx, offset string
    mov ecx, lengthof string
    call sort_string
    ; ...
    ; Output sorted string here
    ; ...
    ret
main endp

sort_string proc
    push ebp
    mov ebp, esp
    ; ...
    ; Sort the characters of the string here
    ; ...
    pop ebp
    ret
sort_string endp
Sign up to request clarification or add additional context in comments.

1 Comment

Bubble Sort is an in-place sorting algorithm. If you want to copy-and-sort into a separate sorted db 20 dup(?) buffer, you'd have to use a better algorithm like Insertion Sort. You're not showing an implementation of a sort (there are many duplicates for that), or for reading user input (again many duplicates), just a skeleton of a different problem, copy-and-sort of a hard-coded string.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.