Question: I want to sort my array according to the timestamp.My array is this 

```
[
  {
    who: 'User',
    msg: 'how are you?',
    time: '9:24:19'
  },
  {
    who: 'Bot',
    msg: 'I am fine. Thank you. How are you?',
    time: '9:24:30'
  },
  {
    who: 'User',
    msg: 'hi',
    time: '9:24:36'
  },
  {
    who: 'Bot',
    msg: 'hello i am Joe',
    time: '9:24:47'
  }
]

```

And when I'm sorting it as a string it is working fine but when I use Date.parse(time) nothing his happening.The problem of sorting it as a string is that when I have 23:11:8 and 23:11: 36, it considers 23:11:36 as the small one.
What to do?

Here is my code

```
var msg1 = msg.sort((a, b) => {
  console.log('sorting');

  var nameA = a.time; // ignore upper and lowercase
  var nameB = b.time; // ignore upper and lowercase
  console.log(nameA + " " + nameB + " " + Date.parse(nameA) + " " + Date.parse(nameB));
  if (nameA < nameB) {
    console.log('sorting');
    return -1;
  }
  if (nameA > nameB) {
    console.log('sorting');
    return 1;
  }

  // names must be equal
  return 0;
})

```

Answer: 
Since you are using c++17 in your code, I thought it would make sense to point out that there are a lot of new tools to avoid having to make these kind of recursive templates.

You could condense the whole thing to this:

```
#include <iostream>
#include <type_traits>
#include <tuple>

template <typename T1, typename... T2>
constexpr bool check_for_type(std::tuple<T2...>) {
    return std::disjunction_v<std::is_same<T1, T2>...>;
}

int main() {
    std::tuple<int, char, bool> tup;
    std::cout << check_for_type<char>(tup) << '\n';
    std::cout << check_for_type<float>(tup) << std::endl;
    return 0;
}

```

If `std::disjunction` gets no parameters it defaults to false, so passing an empty tuple is also covered here.
> 
> 
> ```
> template<class X, class F, class... R>
> constexpr bool check_for_type(tuple<F,R...> t) {
>     if constexpr(is_same<F,X>::value) {
>         return true;
>     } 
>     return check_for_type<X>(tail(t));
> }
> 
> ```
> 
> 

You are calling `check_for_type<X>(...)` before it is declared. Helpfully, your error message states:

> 
> 
> ```
> t.cpp:58:16: note: 'check_for_type' should be declared prior to the call site
> constexpr bool check_for_type(tuple<> t) {
> 
> ```
> 
> 

Once you do that, the code [compiles](https://godbolt.org/g/x6zR2e):

```
// Put this function first
template<class X>
constexpr bool check_for_type(tuple<> t) {
    return false;
}

template<class X, class F, class... R>
constexpr bool check_for_type(tuple<F,R...> t) {
    if constexpr(is_same<F,X>::value) {
        return true;
    }
    // Right here, the compiler looks up `check_for_type` and doesn't find
    // an overload that can be called with just one explicit type parameter.
    return check_for_type<X>(tail(t));
}

```