Example usage for java.util Arrays sort

List of usage examples for java.util Arrays sort

Introduction

In this page you can find the example usage for java.util Arrays sort.

Prototype

public static void sort(Object[] a) 

Source Link

Document

Sorts the specified array of objects into ascending order, according to the Comparable natural ordering of its elements.

Usage

From source file:com.github.fengtan.sophie.beans.Config.java

/**
 * Get Solr servers listed as favorites in the properties file.
 * /*from  w w  w  . jav  a2 s .com*/
 * @return Array of Solr servers (either Solr URL's or ZooKeeper hosts).
 */
public static String[] getFavorites() {
    try {
        String[] favorites = getConfiguration().getStringArray("favorites");
        Arrays.sort(favorites);
        return favorites;
    } catch (ConfigurationException e) {
        // Silently return no favorite and log the exception.
        Sophie.log.warn("Unable to get favorites from configuration file", e);
        return ArrayUtils.EMPTY_STRING_ARRAY;
    }
}

From source file:edu.umn.cs.spatialHadoop.core.ZCurvePartitioner.java

/**
 * Create a ZCurvePartitioner from a list of points
 * @param vsample/*from  ww w  .j a  v  a2  s  .  c  o  m*/
 * @param inMBR
 * @param partitions
 * @return
 */
protected void createFromZValues(final long[] zValues, int partitions) {
    Arrays.sort(zValues);

    this.zSplits = new long[partitions];
    long maxZ = computeZ(mbr, mbr.x2, mbr.y2);
    for (int i = 0; i < partitions; i++) {
        int quantile = (int) ((long) (i + 1) * zValues.length / partitions);
        this.zSplits[i] = quantile == zValues.length ? maxZ : zValues[quantile];
    }
}

From source file:com.github.lucapino.sheetmaker.parsers.mediainfo.MediaInfoExtractor.java

private void print(String rootPath) throws Exception {
    FileFilter filter = new FileFilter() {

        @Override/*from  ww  w. j a v  a2 s  . c om*/
        public boolean accept(File pathname) {
            String lowerCaseName = pathname.getName().toLowerCase();
            return (lowerCaseName.endsWith("ifo") && lowerCaseName.startsWith("vts"))
                    || lowerCaseName.endsWith("mkv") || lowerCaseName.endsWith("iso")
                    || lowerCaseName.endsWith("avi");
        }
    };
    // parse all the tree under rootPath
    File rootFolder = new File(rootPath);
    File[] files = rootFolder.listFiles();
    Arrays.sort(files);
    Map<File, List<File>> mediaMap = new TreeMap<>();
    for (File file : files) {
        System.out.println(file.getName());
        // name of the folder -> name of media
        List<File> fileList;
        if (file.isDirectory()) {
            fileList = recurseSubFolder(filter, file);
            if (!fileList.isEmpty()) {
                System.out.println("adding " + fileList);
                mediaMap.put(file, fileList);
            }
        } else {
            if (filter.accept(file)) {
                fileList = new ArrayList<>();
                fileList.add(file);
                System.out.println("adding " + fileList);
                mediaMap.put(file, fileList);
            }
        }
    }
    Set<File> fileNamesSet = mediaMap.keySet();
    File outputFile = new File("/home/tagliani/tmp/HD-report.xls");
    Workbook wb = new HSSFWorkbook(new FileInputStream(outputFile));
    Sheet sheet = wb.createSheet("Toshiba");

    MediaInfo MI = new MediaInfo();
    int j = 0;
    for (File mediaFile : fileNamesSet) {
        List<File> filesList = mediaMap.get(mediaFile);
        for (File fileInList : filesList) {
            List<String> audioTracks = new ArrayList<>();
            List<String> videoTracks = new ArrayList<>();
            List<String> subtitlesTracks = new ArrayList<>();
            MI.Open(fileInList.getAbsolutePath());

            String durationInt = MI.Get(MediaInfo.StreamKind.General, 0, "Duration", MediaInfo.InfoKind.Text,
                    MediaInfo.InfoKind.Name);
            System.out.println(fileInList.getName() + " -> " + durationInt);
            if (StringUtils.isNotEmpty(durationInt) && Integer.valueOf(durationInt) >= 60 * 60 * 1000) {

                Row row = sheet.createRow(j);
                String duration = MI.Get(MediaInfo.StreamKind.General, 0, "Duration/String",
                        MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                // Create a cell and put a value in it.
                row.createCell(0).setCellValue(WordUtils.capitalizeFully(mediaFile.getName()));
                if (fileInList.getName().toLowerCase().endsWith("iso")
                        || fileInList.getName().toLowerCase().endsWith("ifo")) {
                    row.createCell(1).setCellValue("DVD");
                } else {
                    row.createCell(1)
                            .setCellValue(FilenameUtils.getExtension(fileInList.getName()).toUpperCase());
                }
                row.createCell(2).setCellValue(FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(mediaFile)));
                // row.createCell(3).setCellValue(fileInList.getAbsolutePath());
                row.createCell(3).setCellValue(duration);
                // MPEG-2 720x576 @ 25fps 16:9
                String format = MI.Get(MediaInfo.StreamKind.Video, 0, "Format", MediaInfo.InfoKind.Text,
                        MediaInfo.InfoKind.Name);
                row.createCell(4).setCellValue(format);
                String width = MI.Get(MediaInfo.StreamKind.Video, 0, "Width", MediaInfo.InfoKind.Text,
                        MediaInfo.InfoKind.Name);
                String height = MI.Get(MediaInfo.StreamKind.Video, 0, "Height", MediaInfo.InfoKind.Text,
                        MediaInfo.InfoKind.Name);
                row.createCell(5).setCellValue(width + "x" + height);
                String fps = MI.Get(MediaInfo.StreamKind.Video, 0, "FrameRate", MediaInfo.InfoKind.Text,
                        MediaInfo.InfoKind.Name);
                row.createCell(6).setCellValue(fps);
                String aspectRatio = MI.Get(MediaInfo.StreamKind.Video, 0, "DisplayAspectRatio/String",
                        MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                row.createCell(7).setCellValue(aspectRatio);

                int audioStreamNumber = MI.Count_Get(MediaInfo.StreamKind.Audio);
                for (int i = 0; i < audioStreamNumber; i++) {
                    String audioTitle = MI.Get(MediaInfo.StreamKind.Audio, i, "Title", MediaInfo.InfoKind.Text,
                            MediaInfo.InfoKind.Name);
                    String language = MI.Get(MediaInfo.StreamKind.Audio, i, "Language/String3",
                            MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                    String codec = MI.Get(MediaInfo.StreamKind.Audio, i, "Codec", MediaInfo.InfoKind.Text,
                            MediaInfo.InfoKind.Name);
                    String channels = MI.Get(MediaInfo.StreamKind.Audio, i, "Channel(s)",
                            MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                    String sampleRate = MI.Get(MediaInfo.StreamKind.Audio, i, "SamplingRate/String",
                            MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                    // AC3 ITA 5.1 48.0KHz
                    StringBuilder sb = new StringBuilder();
                    if (StringUtils.isEmpty(audioTitle)) {
                        sb.append(codec).append(" ").append(language.toUpperCase()).append(" ")
                                .append(channels);
                    } else {
                        sb.append(audioTitle);
                    }
                    sb.append(" ").append(sampleRate);
                    audioTracks.add(sb.toString());
                }

                int textStreamNumber = MI.Count_Get(MediaInfo.StreamKind.Text);
                for (int i = 0; i < textStreamNumber; i++) {
                    String textLanguage = MI.Get(MediaInfo.StreamKind.Text, i, "Language/String",
                            MediaInfo.InfoKind.Text, MediaInfo.InfoKind.Name);
                    subtitlesTracks.add(textLanguage);
                }
                MI.Close();
                row.createCell(8).setCellValue(audioTracks.toString());
                row.createCell(9).setCellValue(subtitlesTracks.toString());
                j++;
            }

        }

        //            System.out.println(mediaName);
    }
    try (FileOutputStream fileOut = new FileOutputStream(outputFile)) {
        wb.write(fileOut);
    }

}

From source file:com.meals.on.wheels.MealsOnWheelsApplication.java

@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
    return args -> {

        if (LOGGER.isDebugEnabled()) {

            LOGGER.debug("Let's inspect the beans provided by Spring Boot:");

            String[] beanNames = ctx.getBeanDefinitionNames();
            Arrays.sort(beanNames);
            for (String beanName : beanNames) {
                LOGGER.debug(beanName);/*  w w w  . j av  a 2 s  . co m*/
            }
        }
    };
}

From source file:edu.upf.bioevo.manhattanPlotter.QQPlot.java

void setExperiment(Experiment experiment) {
    this.experiment = experiment;

    // Creates ordered array with log10 observed values
    orderedLog10ObservedValues = new double[experiment.tests.length];
    for (int i = 0; i < experiment.tests.length; i++) {
        orderedLog10ObservedValues[i] = experiment.tests[i].logPValue;
    }//from w w w .ja  v  a  2  s .co m
    Arrays.sort(orderedLog10ObservedValues);
    maxObservedLogValue = orderedLog10ObservedValues[orderedLog10ObservedValues.length - 1];

    // Creates ordered array with log10 exepected values
    orderedLog10ExpectedValues = new double[experiment.tests.length];
    for (int i = experiment.tests.length; i > 0; i--) {
        orderedLog10ExpectedValues[experiment.tests.length - i] = -Math
                .log10((double) i / (experiment.tests.length + 1));
    }
    maxExpectedLogValue = orderedLog10ExpectedValues[orderedLog10ExpectedValues.length - 1];

    // Creates CI95 upper and lower values
    if (ic95Option) {
        lowerCI = new double[experiment.tests.length];
        upperCI = new double[experiment.tests.length];

        for (int i = experiment.tests.length - 1; i >= 0; i--) {
            BetaDistribution beta = new BetaDistribution(i + 1, experiment.tests.length - i);
            lowerCI[i] = -Math.log10(beta.inverseCumulativeProbability(0.025));
            upperCI[i] = -Math.log10(beta.inverseCumulativeProbability(0.975));
        }
        Arrays.sort(lowerCI);
        Arrays.sort(upperCI);
    }

}

From source file:net.phoenix.nlp.pos.recognitor.DateTimeRecognitor.java

public DateTimeRecognitor(Dictionary dictionary) throws IOException {
    super(dictionary);
    CharsDictionary chars = dictionary.getDictionary(CharsDictionary.class);
    this.numbers = chars.getChars("datetime.number");
    Arrays.sort(this.numbers);
    this.qualifiers = chars.getChars("datetime.qualifier");
    Arrays.sort(this.qualifiers);
    log.info("DateTimeRecognitor ready.");
}

From source file:io.warp10.continuum.gts.GTSOutliersHelper.java

protected static double medianAbsoluteDeviation(GeoTimeSerie gts, double median) {
    double[] copy = Arrays.copyOf(gts.doubleValues, gts.values);
    for (int i = 0; i < gts.values; i++) {
        copy[i] -= median;//from w  w w.  j  a  v a 2  s  .  c om
        copy[i] = Math.abs(copy[i]);
    }
    Arrays.sort(copy);

    return gts.values % 2 == 0 ? (copy[gts.values / 2] + copy[gts.values / 2 - 1]) / 2 : copy[gts.values / 2];
}

From source file:techtonic.WellBoreListenerOnView.java

public WellBoreListenerOnView(int id, WitsmlWellbore wellbore, JPanel pan, JComboBox xAxis, JComboBox yAxis,
        JPanel traj, JPanel logsPanel) {
    this.id = id;
    this.wellbore = wellbore;
    this.seriesMagger = seriesMagger;
    this.xAxis = xAxis;
    this.yAxis = yAxis;
    this.trajectoryPanel = traj;
    this.logPanel = logsPanel;

    chartPanel = pan;//w  ww. j av a  2  s.co m
    talker++;
    Arrays.sort(wellborePlot);

}

From source file:it.unimi.di.big.mg4j.index.cluster.FrequencyLexicalStrategy.java

/** Creates a new subset lexical strategy.
 * @param subset the subset of terms.//from  ww  w  . j a va  2s .  c o m
 */
public FrequencyLexicalStrategy(final LongSet subset) {
    final long[] t = subset.toLongArray();
    Arrays.sort(t);
    localNumber = new Long2LongOpenHashMap();
    localNumber.defaultReturnValue(-1);
    for (int i = 0; i < t.length; i++)
        localNumber.put(t[i], i);
}

From source file:org.objectrepository.instruction.ServiceBaseImp.java

/**
 * @param folder/*from ww  w.  j  av a 2 s .  c o  m*/
 * @param instruction
 */
private void getFolders(File folder, OrIterator instruction) {
    File[] files = folder.listFiles();
    Arrays.sort(files);
    for (File file : files) {
        if (Counting.skip(file.getName())) { // Ignore the self and hidden folders.
            continue;
        }
        if (file.isDirectory()) {
            log.debug("folder " + folder.getName());
            this.getFolders(file, instruction);
        } else {
            log.info("stagingfile " + file.getAbsolutePath());
            objectFromFile(file, instruction);
        }
    }
}