Translate: - English

This is a tutorial on Automatically Sorting New List Entries alphabetically and numerically. This tutorial will teach you how to tell Scratch to differentiate between a number and a word, and then how to sort it.

## How to do it

First of all, you will need four variables and four lists. In this tutorial, they will be:

• Variables
• # - An iterator
• NFirst - Number First
• WFirst - Word First
• Var - Another iterator
• Lists
• Numbers - A hidden list of numbers
• Sorted Numbers - A shown list, which shows all the numbers in numerical order
• Words - A hidden list of words
• Sorted Words - A shown list, which shows all the words in alphabetical order

Then you need to create this script:

```when gf clicked
set [NFirst v] to 
set [WFirst v] to 
delete (all v) of [Numbers v]
delete (all v) of [Sorted Numbers v]
delete (all v) of [Words v]
delete (all v) of [Sorted Words v]
```

Then you will need to broadcast something which will tell an ask block to ask a question.

```when I receive [Question v]
change [NFirst v] by (1)
else
change [WFirst v] by (1)
end
```

That script determined whether the input was a number or a word. Note: If a number has a decimal point or spaces in it, it will be counted as a word.

Depending on whether it is a number or a word, that script broadcasted "numbers" or "words."

```when I receive [Words v]
set [# v] to 
stop [this script v]
else
if <(WFirst) = > then
add [] to [Sorted Words v]
set [Var v] to 
repeat (length of [Words v])
replace item (Var) of [Sorted Words v] with (item (((length of [Words v]) - (Var)) + (1)) of [Words v])
change [Var v] by (1)
end
stop [this script v]
else
repeat ((length of [Words v]) + (1))
if <(answer) < (item (#) of [Words v])> then
change [# v] by (1)
else
insert (answer) at (#) of [Words v]
add [] to [Sorted Words v]
set [Var v] to 
repeat (length of [Words v])
replace item (Var) of [Sorted Words v] with (item (((length of [Words v]) - (Var)) + (1)) of [Words v])
change [Var v] by (1)
end