Sort primes from list to a list

From Rosetta Code
Revision as of 12:55, 22 January 2022 by CalmoSoft (talk | contribs) (Created page with "{{Draft task}} ;Task: <br> Let given list: <br> Primes = [2,43,81,122,63,13,7,95,103] <<br> Show on this page the ascending ordered list of primes from given list. =={{heade...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Sort primes from list to a list is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
Task


Let given list:
Primes = [2,43,81,122,63,13,7,95,103] <
Show on this page the ascending ordered list of primes from given list.

Ring

<lang ring> load "stdlibcore.ring" ? "working"

Primes = [2,43,81,122,63,13,7,95,103] Temp = []

for n = 1 to len(Primes)

    if isprime(Primes[n])
       add(Temp,Primes[n])
    ok

next

Temp = sort(Temp) ? Temp ? "done..." </lang>

Output:
working
Primes are:
2
7
13
43
103
done...