<commit_before>using System;
using System.Linq;
using System.Linq.Expressions;
using DevLab.JmesPath.Expressions;
using DevLab.JmesPath.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using JmesPathFunction = DevLab.JmesPath.Interop.JmesPathFunction;

namespace DevLab.JmesPath.Functions
{
    public class SortFunction : JmesPathFunction
    {
        public SortFunction()
            : base("sort", 1)
        {

        }
        public override bool Validate(params JmesPathArgument[] args)
        {
            var list = args[0].AsJToken();
            if(list.Type != JTokenType.Array)
                throw new Exception("invalid-type");

            return true;
        }

        public override JToken Execute(params JmesPathArgument[] args)
        {
            var list = (JArray)(args[0].AsJToken()).AsJEnumerable();
            var ordered = list.OrderBy(u => u.Value<String>()).ToArray();
            return new JArray(ordered.AsJEnumerable());
        }
    }
}<commit_msg>fix - sort need a array of element with the same type.<commit_after>using System;
using System.Linq;
using System.Linq.Expressions;
using DevLab.JmesPath.Expressions;
using DevLab.JmesPath.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using JmesPathFunction = DevLab.JmesPath.Interop.JmesPathFunction;

namespace DevLab.JmesPath.Functions
{
    public class SortFunction : JmesPathFunction
    {
        public SortFunction()
            : base("sort", 1)
        {

        }
        public override bool Validate(params JmesPathArgument[] args)
        {
            var list = args[0].AsJToken();
            if(list.Type != JTokenType.Array)
                throw new Exception("invalid-type");
            var arg = ((JArray) list);
            if (arg.Count != 0)
            {
                var types = arg.Select(u => u.Type).Distinct();
                if (types.Count() != 1)
                    throw new Exception("invalid-type");
            }
            return true;
        }

        public override JToken Execute(params JmesPathArgument[] args)
        {
            var list = (JArray)(args[0].AsJToken()).AsJEnumerable();
            var ordered = list
                .OrderBy(u => u.Value<String>())
                .ToArray();
            return new JArray(ordered.AsJEnumerable());
        }
    }
}
{'fraction_non_alphanumeric': 0.10619834710743802, 'fraction_numerical': 0.003305785123966942, 'mean_word_length': 1.9133574007220218, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5775218', 'n_tokens_mistral': 684, 'n_tokens_neox': 673, 'n_words': 147}