# How to make a sorted list block in snap.

I have an assignment due and I am having trouble figuring it out. My assignment requires I create a sorted list block that takes a list of numbers as input and reports a new list, where the numbers are sorted from least to greatest.
Any help is appreciated, I'm new to coding and am very stuck on this.

Have a search on the internet for bubble sort

Once you've understood how a bubble sort works, then have a go at implementing it in Snap!

If you get stuck at some point - come back and tell us which bit your stuck at

Don't reimplement the wheel!

(you should have the extension support open)
Blame your teacher for giving you such a redundant practice(he could make you do a dfs algorithm or other stuff)

I believe the common practice for assignment help is not to provide solutions directly, but instead, to guide people on the path to solutions.

The OP is studying computer science and wants to learn about sort algoriths by implementing one. You understand that perfectly well.

So saying, in effect, "Somebody else has already solved this problem, so there's no reason for you to learn it" is nothing but insuting the OP and showing off how much smarter you are. And that's not even true! He's smarter than you, because he knows that there's a lot he needs to learn, whereas you think you know it all.

We don't tolerate bullying on this site. Take this as a warning.

Hi, welcome to the forum! Most of us are friendly and want to be helpful. :~)

What I'd suggest is to start by thinking of how you sort things not with a computer. Cards in your hand in a card game. Recipes on index cards. Books in your bookcase. Don't try to be super smart about it; look for a simple method.

Then, if you're stuck at implementing it, ask us for help, but explain your algorithm and show us what you tried.

Oh.

I'm not bullying

Yes, actually, you are. You're saying that sorting is such a trivial problem that everyone should know how to do it without being taught.

But I don't have time to argue over words. Whatever you want to call it, don't do it.

No!I mean't that you should not reinvent the wheel and you should know the extension blocks(just knew that this guy did not want to cheat on his practice)

From wikipedia: 2 simple algorithm (see main article link)

#### Insertion sort

Main article: Insertion sort

Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and is often used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list similar to how we put money in our wallet.[20] In arrays, the new list and the remaining elements can share the array's space, but insertion is expensive, requiring shifting all following elements over by one. Shellsort is a variant of insertion sort that is more efficient for larger lists.

#### Selection sort

Main article: Selection sort

Selection sort is an in-place comparison sort. It has O(n 2) complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and also has performance advantages over more complicated algorithms in certain situations.

The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list.[21] It does no more than n swaps, and thus is useful where swapping is very expensive.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.