# Sorting Colors with sortMode errors

**URL:** <https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651>\
**Category:** Coding Questions\
**Created:** [March 14, 2020, 12:57pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651 "2020-03-14T12:57:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![wendyT](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wendyT](https://discourse.processing.org/u/wendyT)\
**Post date:** [March 14, 2020, 12:57pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/1 "2020-03-14T12:57:02Z")

</div>

I’m playing with examples in the “Generative Design” book - this example builds an array of colors from an image and then sorts them.

I get an error message:

> Uncaught ReferenceError: gd is not defined (sketch: line 69)  
> Line 69 = gd.sortColors(colors, sortMode);

does this capability no longer exist? or done differently now? I can’t find any information about it in the online reference.

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 14, 2020, 12:59pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/2 "2020-03-14T12:59:53Z")

</div>

gd seems to be an object derived from a class.

Did you import the library for generative design (gd)?

import generativedesign.\*;

Do other sketches run?

Can you please share the link?

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 14, 2020, 4:28pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/3 "2020-03-14T16:28:42Z")

</div>

Hello,

Which example?

[http://www.generative-gestaltung.de/1/code](http://www.generative-gestaltung.de/1/code)

`:)`

---

<div class="post-metadata">

**Author:** ![wendyT](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wendyT](https://discourse.processing.org/u/wendyT)\
**Post date:** [March 14, 2020, 5:13pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/4 "2020-03-14T17:13:09Z")

</div>

Hi Chrisr - thanks for the reply!

I’m pretty new to coding. So far all the other sketches I’ve tried worked fine. While I have sublime installed I’ve not figured out how to use well yet and so I’ve been sticking to the P5 web editor. Should I be somehow uploading the library to the web editor?

Not sure what link you would be refering to…

---

<div class="post-metadata">

**Author:** ![wendyT](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wendyT](https://discourse.processing.org/u/wendyT)\
**Post date:** [March 14, 2020, 5:16pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/5 "2020-03-14T17:16:36Z")

</div>

Hi glv,

Hmm - I followed your link and this it the particular code I’m trying to run

[http://www.generative-gestaltung.de/1/P\_1\_2\_2\_01](http://www.generative-gestaltung.de/1/P_1_2_2_01)

I do notice that the version of the package I installed via the url provide in the book is 1.1.0 and I see more current versions on your link. I’ve been copying the sketch files I downloaded into the web editor to run them. Per Chrisir’s reply perhaps I need to also upload a library?

---

<div class="post-metadata">

**Author:** ![wendyT](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wendyT](https://discourse.processing.org/u/wendyT)\
**Post date:** [March 14, 2020, 5:22pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/6 "2020-03-14T17:22:58Z")

</div>

Apologies for multiple replies - looks like the versions on this link are for Processing, but I downloaded and am working with P5.js

Sorry for any confusion - I’m really new at this!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 14, 2020, 5:24pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/7 "2020-03-14T17:24:58Z")

</div>

I also just noticed the P5.js:

[http://www.generative-gestaltung.de/2/](http://www.generative-gestaltung.de/2/)

I have both books and have yet to open them… a recent purchase.

`:)`

---

<div class="post-metadata">

**Author:** ![wendyT](https://avatars.discourse-cdn.com/v4/letter/w/f05b48/32.png) [@wendyT](https://discourse.processing.org/u/wendyT)\
**Post date:** [March 14, 2020, 5:29pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/8 "2020-03-14T17:29:50Z")

</div>

The books are really great inspirations!

here is the P5 example  
[http://www.generative-gestaltung.de/2/sketches/?01\_P/P\_1\_2\_2\_01](http://www.generative-gestaltung.de/2/sketches/?01_P/P_1_2_2_01)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 15, 2020, 9:56am UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/9 "2020-03-15T09:56:51Z")

</div>

> [@wendyT](#):
>
> here is the P5 example  
> [http://www.generative-gestaltung.de/2/sketches/?01\_P/P\_1\_2\_2\_01](http://www.generative-gestaltung.de/2/sketches/?01_P/P_1_2_2_01)

It is stuck on “Loading …” in the preview pane of P5 Editor.

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [March 25, 2020, 8:12pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/10 "2020-03-25T20:12:45Z")

</div>

> [@wendyT](#):
>
> Uncaught ReferenceError: gd is not defined (sketch: line 69)

Were you able to resolve this error? If you are running Generative Design sketches in Processing’s default Java mode, then you need to install the Generative Design library through the PDE Contributions Manager.

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 26, 2020, 11:39pm UTC](https://discourse.processing.org/t/sorting-colors-with-sortmode-errors/18651/11 "2020-03-26T23:39:11Z")

</div>

It works with this:  
[http://www.generative-gestaltung.de/2/sketches/?01\_P/P\_1\_2\_2\_01](http://www.generative-gestaltung.de/2/sketches/?01_P/P_1_2_2_01)

It works if I install this:

> **[generative-design/Code-Package-p5.js](https://github.com/generative-design/Code-Package-p5.js)**
>
> Code package of the book: Generative Design – Creative Coding for the Web with JavaScript in p5.js - generative-design/Code-Package-p5.js

  
I had to install option 2 as per **README.md** to launch same page (as above example) and run it locally. I already had Node.js so it was simple for me. The other examples did not require the server; just this one and I could run just opening index.html for examples.

`:)`
