Parse all tokens from the file and return them sorted and cleaned.

@param sort If true it will sort the variables.

@return A string with the original file data sorted.
517520
public function getSortedFile($sort = true)
    {
        if (!$this->tokens->valid()) {
            $this->logger->info('File is empty.');
        }
        while ($this->tokens->valid()) {
            $this->logger->info('parsing next block');
            $this->parseNextBlock();
        }
        if ($sort) {
            ksort($this->var_blocks);
        }
        $this->var_blocks = array_values($this->var_blocks);
        $blocks = array_merge($this->empty_blocks, $this->var_blocks, $this->end_blocks);

        return implode('', $blocks);
    }
945332
public static <T> OutputPortCloseable<T> sort(
            OutputPort<T> initialSource,
            Comparator<T> comparator,
            int chunkSize,
            Class<T> clazz,
            File tempFile) throws IOException {
        return sort(initialSource, comparator, chunkSize,
                new ObjectSerializer.PrimitivIOObjectSerializer<>(clazz), tempFile);
    }
11635
private String sortXml(final String originalXml) {

        xmlProcessingInstructionParser.scanForIgnoredSections(originalXml);
        String xml = xmlProcessingInstructionParser.replaceIgnoredSections();

        insertXmlInXmlProcessor(xml, () -> "Could not sort " + pomFile.getAbsolutePath() + " content: ");
        xmlProcessor.sortXml();
        Document newDocument = xmlProcessor.getNewDocument();

        String sortedXml = xmlOutputGenerator.getSortedXml(newDocument);
        if (xmlProcessingInstructionParser.existsIgnoredSections()) {
            sortedXml = xmlProcessingInstructionParser.revertIgnoredSections(sortedXml);
        }
        return sortedXml;
    }
1277601
def sort(self, order="asc"):
        
        self.__prepare()
        if isinstance(self._json_data, list):
            if order == "asc":
                self._json_data = sorted(self._json_data)
            else:
                self._json_data = sorted(self._json_data, reverse=True)

        return self
803585
private Node parseResultType() {
    skipEOLs();
    if (!match(JsDocToken.COLON)) {
      return newNode(Token.EMPTY);
    }

    next();
    skipEOLs();
    if (match(JsDocToken.STRING) && "void".equals(stream.getString())) {
      next();
      return newNode(Token.VOID);
    } else {
      return parseTypeExpression(next());
    }
  }
703654
public static Array<FileHandle> sortFiles (FileHandle[] files, Comparator<FileHandle> comparator) {
		return sortFiles(files, comparator, false);
	}
1364083
def parse_sort_string(sort):
    
    if sort is None:
        return ['_score']
    l = sort.rsplit(',')
    sortlist = []
    for se in l:
        se = se.strip()
        order = 'desc' if se[0:1] == '-' else 'asc'
        field = se[1:] if se[0:1] in ['-', '+'] else se
        field = field.strip()
        sortlist.append({field: {"order": order, "unmapped_type": "string", "missing": "_last"}})
    sortlist.append('_score')
    return sortlist
426714
public function find($regexpPattern = '.*', $sort = false)
    {
        list(, $files) = $this->read($sort);

        return array_values(preg_grep('/^' . $regexpPattern . '$/i', $files));
    }
837805
public static Set extractStringsInbetweenTagsFromText(String input, char startTag, char endTag, boolean sort) {
		
		TreeMap<String, Object> storage = new TreeMap<String, Object>();
		HashSet<String> unsortedStorage = new HashSet<String>();

		StringBuffer word = new StringBuffer();
		boolean readingWord = false;
		LOOP:
		for (int i = 0; i < input.length(); i++) {
			if (readingWord) {
				if (input.charAt(i) == endTag) {
					//check forbidden word list first
					//or maybe make arrangements in Index
					//e.g.: disable Index with too many (%) references


					String foundWord = word.toString();
					if (!sort) {
						if (!storage.containsKey(foundWord)) {
							unsortedStorage.add(foundWord);
						}
					}


					storage.put(foundWord, new Object());
					readingWord = false;
					continue LOOP;
				}
				else {
					word.append(input.charAt(i));
				}
			}
			else {
				if (input.charAt(i) == startTag) {
					word = new StringBuffer();
					readingWord = true;
				}
				else {
					continue LOOP;
				}
			}
		}
		if (readingWord) {
			String foundWord = word.toString()/*.toLowerCase()*/;
			if (!sort) {
				if (!storage.containsKey(foundWord)) {
					unsortedStorage.add(foundWord);
				}
			}
			storage.put(foundWord, new Object());
		}
		if (sort) {
			return storage.keySet();
		}
		else {
			return unsortedStorage;
		}
	}
545617
public static String sort(String list, String sortType, String sortOrder, String delimiter) throws PageException {
	return _sort(toStringArray(listToArray(list, delimiter)), sortType, sortOrder, delimiter);
    }
1367487
public String[] tokenise(String string) {
		String str = string;
		if(str == null || str.length() == 0) {
			return null;
		}
		List<String> list = new ArrayList<String>();
		int length = delimiter.length();
		int idx = str.indexOf(delimiter);
		while(idx != -1) {
			String token = str.substring(0, idx);
			str = str.substring(idx + length);
			if(trimTokens) {
				token = token.trim();
			}			
			if(!skimEmpty || token.length() > 0) {
				list.add(token);
			}			
			idx = str.indexOf(delimiter);
		}
		
		// handle the case where there is only one token
		// or there is a token after the last separator
		if(str.trim().length() > 0) {
			if(trimTokens) {
				str = str.trim();
			}
			list.add(str);
		}
		
		String [] tokens = new String[list.size()];
		list.toArray(tokens);
		return tokens;
	}
647867
protected function parseSort($sort)
    {
        $type = substr($sort, 0, 1);
        $key = substr($sort, 1);

        switch ($type) {
            case '+': $type = Sort::TYPE_ASC; break;
            case '-': $type = Sort::TYPE_DESC; break;
            default:
                throw new NoSuchSortException();
        }

        return new Sort($type, $key);
    }
45654
public static String getPatternFromFile(BufferedReader reader) throws IOException {
    StringBuilder matchString = new StringBuilder();
    for (String thisLine; (thisLine = reader.readLine()) != null; ) {
      if (matchString.length() > 0 && emptyLinePattern.matcher(thisLine).matches()) {
        // A blank line after getting some real content (not just comments or nothing)
        break;
      }
      Matcher m = commentPattern.matcher(thisLine);
      if (m.matches()) {
        // delete it
        thisLine = m.replaceFirst("");
      }
      if ( ! emptyLinePattern.matcher(thisLine).matches()) {
        matchString.append(thisLine);
      }
    }
    return matchString.toString();
  }
323678
public CoreRemoteFindIterableImpl<DocumentT, ResultT> sort(@Nullable final Bson sort) {
    findOptions.sort(sort);
    return this;
  }
684484
public void sortPrefixes() {
        for (final Field field : ScanSpec.class.getDeclaredFields()) {
            if (WhiteBlackList.class.isAssignableFrom(field.getType())) {
                try {
                    ((WhiteBlackList) field.get(this)).sortPrefixes();
                } catch (final ReflectiveOperationException e) {
                    throw ClassGraphException.newClassGraphException("Field is not accessible: " + field, e);
                }
            }
        }
    }
226491
def parse_tokens(data)
      tokens = {}
      data.split("\n").each do |t|
        tokens.merge!({ t.split('=').first.downcase.to_sym => t.split('=').last })
      end
      return tokens
    end
968186
final String toTokenString() throws IOException {
    String[] stringToFormat = toFinalString(null);
    return String.join("|", Arrays.asList(stringToFormat));
  }