Question: So brand new to Python, trying to get past this django error:

```
NameError at /hello/
name 'HttpResponse' is not defined
Request Method:
GET
Request URL:
http://localhost:61892/hello/
Django Version:
1.11.7
Exception Type:
NameError
Exception Value:
name 'HttpResponse' is not defined
Exception Location:
c:\users\mblaylock\source\repos\mysite\mysite\mysite\views.py in hello, line 6
Python Executable:
c:\users\mblaylock\source\repos\mysite\mysite\env\Scripts\python.exe
Python Version:
3.6.2
Python Path:
['c:\\users\\mblaylock\\source\\repos\\mysite\\mysite',
 'c:\\users\\mblaylock\\source\\repos\\mysite\\mysite',
 'c:\\users\\mblaylock\\source\\repos\\mysite\\mysite\\env\\Scripts\\python36.zip',
 'C:\\Program Files\\Python36\\DLLs',
 'C:\\Program Files\\Python36\\lib',
 'C:\\Program Files\\Python36',
 'c:\\users\\mblaylock\\source\\repos\\mysite\\mysite\\env',
 'c:\\users\\mblaylock\\source\\repos\\mysite\\mysite\\env\\lib\\site-packages']
Server time:
Mon, 13 Nov 2017 18:09:39 +0000

```

My code is:

```
class views(object):

    """description of class"""

    from django.http import HttpResponse

def hello(request):
    return HttpResponse("Hello world")

```

Using Visual Studio for my IDE on Windows 10, if that matters.

Thanks in advance!

Answer: 
It sounds like you are doing:

```
data.sort(function(a, b) {
    //sort by provider
});

data.sort(function(a, b) {
    //sort by measure
});

```

But what you want to do is:

```
data.sort(function(a, b) {
    //sort by provider, but if they are equal, sort by measure
});

```

So something like

```
data.sort(function(a, b) {
    if (a.provider === b.provider) {
        return a.measure.localeCompare(b.measure);
    }
    return b.provider.localeCompare(a.provider);
});

```
You could chain the sorting criteria with [logical OR `||`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators#Logical_OR_()).

> 
> For a set of strings with a defined order, you could use an object for getting the wanted order.
> 
> 
> 
> ```
> {
>     first_quartile: 1,
>     median: 2,
>     third_quartile: 3
> }
> 
> ```
> 
> This lets you sort some item, if not in the order list ssort to start with default zero or to bottom with a huge value like `Infinity`.
> 
> 
> In this case the pattern looks like
> 
> 
> 
> ```
> (order[a.measure] || 0) - (order[a.measure] || 0)                // to top
> (order[a.measure] || Infinify ) - (order[a.measure] || Infinity) // to bottom
> 
> ```
> 
> 

```js
var array = [{ deviation: 57.41, provider: "This", measure: "median" }, { deviation: 49.02, provider: "All", measure: "median" }, { deviation: 199.67, provider: "This", measure: "third_quartile" }, { deviation: 152.31, provider: "All", measure: "third_quartile" }, { deviation: 41.48, provider: "This", measure: "first_quartile" }, { deviation: -1.07, provider: "All", measure: "first_quartile" }],
   order = { first_quartile: 1, median: 2, third_quartile: 3 };

array.sort(function (a, b) {
    return b.provider.localeCompare(a.provider) || order[a.measure] - order[b.measure];
});

console.log(array);
```

```css
.as-console-wrapper { max-height: 100% !important; top: 0; }
```